如何在C#中更改wsdl:part name?

问题描述 投票:1回答:1

有没有办法在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个回答
0
投票

在您的网络方法中:

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

© www.soinside.com 2019 - 2024. All rights reserved.