开发者

Create soap request

I've tried to serialize an object with XmlSerializer and SoapFormatter but i can't ge开发者_如何学Ct 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?


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜