2011-05-24 163 views
2

我试图序列与XmlSerializer的和SoapFormatter的对象,但我不能让输出看起来像这样:创建SOAP请求

<?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> 

我的课:

[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; 
     } 
    } 
} 

任何人都可以帮帮我?

回答

2

要记录SoapRequest,请尝试使用MessageInspector或启用Web.Config中的Logging for Web Service。

+0

对于我需要登录肥皂请求?!? – Sys 2011-05-24 11:11:30

0

通常,您不必序列化我们的对象。 您应该通过WSDL-url添加Web引用,并通过生成的代理类调用服务的方法

+0

不幸的是,没有WSDL文件。 – Sys 2011-05-24 11:09:41