Reputation: 17300
Is it possible for a C# WebMethod to accept a different parameter name than its client sends?
For example, given a client sending this message:
<?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>
Can the existing WebMethod be rewritten to accommodate different argument names? Something like this?
[WebMethod]
public string GetStatus(
[MessageParameter(Name = "Arg1")] string orderId,
[MessageParameter(Name = "Arg2")] string typeId)
Upvotes: 3
Views: 2292
Reputation: 546
You should be able to do it with the XmlElementAttribute, e.g:
[WebMethod]
public string GetStatus(
[XmlElementAttribute(ElementName = "Arg1")] string orderId,
[XmlElementAttribute(ElementName = "Arg2")] string typeId)
Upvotes: 11