【问题标题】:How to change wsdl:part name in C#?如何在 C# 中更改 wsdl:part 名称?
【发布时间】:2018-08-31 09:25:28
【问题描述】:

有什么方法可以更改 WSDL 中消息部分的名称吗?

我的 WSDL 中有这个:

<wsdl:message name="myMethodSoapOut">
     <wsdl:part name="myMethodResult" element="s0:myMethodResult"/>
</wsdl:message>

我想将零件名称更改为:

<wsdl:message name="myMethodSoapOut">
     <wsdl:part name="out" element="s0:myMethodResult"/>
</wsdl:message>

【问题讨论】:

    标签: c# .net web-services soap wsdl


    【解决方案1】:

    在您的网络方法中:

    [WebMethod]
    public MyReturnInfo MyMethod(MyInputInfo input)
    {
    //your code
    return yourInfo;
    }
    

    这样说,输出作为out参数返回:

    [WebMethod]
    public void MyMethod(out MyReturnInfo @out, MyInputInfo input)
    {
    //your code
    @out = yourInfo;
    }
    

    在参数中使用“in”和“out”,并保持元素名称正确:

    [WebMethod]
    public void MyMethod( [System.Xml.Serialization.XmlElement("myInfoResponse", Namespace = "the_name_space_of_the_response")]out MyReturnInfo @out,
    [System.Xml.Serialization.XmlElement("myInfoRequest", Namespace = "the_name_space_of_the_request")] MyInputInfo @in)
    {
    var myVar = DoSomething(@in);
    //your code
    @out = yourInfo;
    }
    

    最后是 wsdl:

    <wsdl:message name="myInfoSoapIn">
         <wsdl:part name="in" element="s0:myInfoRequest"/>
    </wsdl:message>
    ...
    <wsdl:message name="myInfoSoapOut">
         <wsdl:part name="out" element="s0:myInfoResponse"/>
    </wsdl:message>
    

    感谢 PD ;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-24
      • 1970-01-01
      • 2023-02-06
      • 2017-09-09
      • 1970-01-01
      • 2015-03-24
      • 2011-08-31
      • 2015-07-24
      相关资源
      最近更新 更多