Reputation: 11
I have developed a WCF service whose response is like this -
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<getNameResponse xmlns="http://tempuri.com/">
<name>4</name>
</getNameResponse>
</s:Body>
</s:Envelope>
But I need response in the following format-
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<a:getNameResponse xmlns:a="http://tempuri.com/">
<name>4</name>
</a:getNameResponse>
</s:Body>
</s:Envelope>
Is it possible to configure WCF service to achieve this behavior?
Upvotes: 1
Views: 778
Reputation: 87293
Yes, you can do this - I've posted about customizing prefixes for WCF services at http://blogs.msdn.com/b/carlosfigueira/archive/2010/06/13/changing-prefixes-in-xml-responses.aspx. However, notice that the two responses you have are not equivalent - in the first one, the <name>
element is on the namespace "http://tempuri.org/", while on the second one, it's on the empty ("") namespace. If that's really what you need, you may want to consider using a message contract to change the namespace of the body elements.
Upvotes: 1