I use WCF to implement a client for a SOAP web service. The code is generated by "Add Service Reference" based on the WSDL file.
The elements of the SOAP request are defined in different namespaces. Now, a sample message looks like this:
<s:Envelope xmlns:s="http://ift.tt/sVJIaE">
<s:Body xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:xsd="http://ift.tt/tphNwY">
<myMethod xmlns="http://ift.tt/1Fx4DIj">
<RequestData>
<Foo xmlns="http://ift.tt/1Lgixib">some</Foo>
<Bar xmlns="http://ift.tt/1Lgixib">thing</Bar>
<Baz xmlns="http://ift.tt/1Lgixib">content</Baz>
<!-- .... more elements .... -->
</RequestData>
</myMethod>
</s:Body>
</s:Envelope>
which contains the redundant definition of the elements namespace. In order to reduce message size, I would prefer to have the namespace definitions at the top of the message, eg. like this:
<s:Envelope xmlns:s="http://ift.tt/sVJIaE">
<s:Body xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:xsd="http://ift.tt/tphNwY"
xmlns:a="http://ift.tt/1Fx4DIj"
xmlns:b="http://ift.tt/1Lgixib">
<a:myMethod>
<a:RequestData>
<b:Foo>some</b:Foo>
<b:Bar xmlns="http://ift.tt/1Lgixib">thing</b:Bar>
<b:Baz xmlns="http://ift.tt/1Lgixib">content</b:Baz>
<!-- .... more elements .... -->
</a:RequestData>
</a:myMethod>
</s:Body>
</s:Envelope>
(I don't really care which parent element defines the namespaces, so any way to move the namespace definitions to Envelope, Body or MyMethod would be okay for me.)
How can I achieve this?
No comments:
Post a Comment