C# WebMethod 是否可以接受与其客户端发送的参数名称不同的参数名称?
例如,假设客户端发送此消息:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetStatus xmlns="http://example.com/">
<Arg1>5</Arg1>
<Arg2>3</Arg2>
</GetStatus>
</soap:Body>
</soap:Envelope>
可以重写现有的 WebMethod 以适应不同的参数名称吗?像这样的东西吗?
[WebMethod]
public string GetStatus(
[MessageParameter(Name = "Arg1")] string orderId,
[MessageParameter(Name = "Arg2")] string typeId)
您应该能够使用 XmlElementAttribute 来完成此操作,例如:
[WebMethod]
public string GetStatus(
[XmlElementAttribute(ElementName = "Arg1")] string orderId,
[XmlElementAttribute(ElementName = "Arg2")] string typeId)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)