【问题标题】:Create soap request创建肥皂请求
【发布时间】:2011-05-24 10:03:23
【问题描述】:

我尝试使用 XmlSerializer 和 SoapFormatter 序列化一个对象,但我无法让输出看起来像这样:

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

谁能帮忙?

【问题讨论】:

    标签: c# serialization soap


    【解决方案1】:

    要记录 SoapRequest,请尝试 MessageInspector 或为 Web 服务启用 Web.Config 中的记录。

    【讨论】:

    • 我需要什么来记录soap请求?!?
    【解决方案2】:

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

    【讨论】:

    • 很遗憾没有 WSDL 文件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-10
    • 1970-01-01
    • 2013-05-19
    • 2020-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多