c# - 如何在 C# 中更改 wsdl:part 名称?
问题描述
是否有任何方法可以更改 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;
}
可以这样说,输出作为输出参数返回:
[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 ;)
推荐阅读
- python - 在 pySpark 中进行逐列减法的最有效方法
- java - 尝试调用虚方法错误 (NullPointerException)
- javascript - 在 javascript 中使用相同的参数组成链式函数
- python - 我需要帮助在 python 中“匹配”和间接”
- python - 具有循环依赖的类型提示
- java - Jhipster jdl 错误 - `需要有效的源和目标实体`
- javascript - 如何触发 CSS 动画
- go - float64 到结果中没有 [] 的字符串
- cucumber - 空手道:从绝对类路径中提取特征文件
- syntax - 需要帮助理解 android.volley.requestQueue 文档示例的语法