How to create SOAP request?

Create soap request

  • I've tried to serialize an object with XmlSerializer and SoapFormatter but i can't get the output to look like this: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Login xmlns="http://www.myfirm.com/2010/core/ConnectTypes"> <UserLogin> <UserName>User</UserName> <Password>PW</Password> <Mandant>1</Mandant> </UserLogin> </Login> </soap:Body> </soap:Envelope> My classes: [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] public partial class UserLoginType { private string userNameField; private string passwordField; private int mandantField; /// <remarks/> public string UserName { get { return this.userNameField; } set { this.userNameField = value; } } /// <remarks/> public string Password { get { return this.passwordField; } set { this.passwordField = value; } } /// <remarks/> public int Mandant { get { return this.mandantField; } set { this.mandantField = value; } } } [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] public partial class LoginType { private object itemField; /// <remarks/> [System.Xml.Serialization.XmlElementAttribute("LoginToken", typeof(string))] [System.Xml.Serialization.XmlElementAttribute("UserLogin", typeof(UserLoginType))] public object Item { get { return this.itemField; } set { this.itemField = value; } } } Can anyone help?

  • Answer:

    To Log the SoapRequest try MessageInspector or enable the Logging in Web.Config for Web Service.

Sys at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

Generally, you do not have to serialize our objects way like that. You should add the Web-Reference via WSDL-url, and invoke methods of the service by the generated proxy class

VMAtm

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.