有什么方法可以更改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>
在你的网络方法中:
[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;)