2011-05-24 218 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