Configure SOAP Header Namespace Prefixes in WCF

I wrote about the way to configure namespaces and namespace prefixes in the SOAP message generated by wcf here .

However, I cannot find a suitable method for overriding in the Message class to configure SOAP message headers.

I want to make this message:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<h:Protocol xmlns="http://www.xyz.de/Protocol" xmlns:h="http://www.xzy.de/Protocol">
<version>IFD_1.4</version>
</h:Protocol>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
</s:Body>
</s:Envelope>

Take a look:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<if:Protocol xmlns="http://www.xyz.de/Protocol" xmlns:if="http://www.xzy.de/Protocol">
<version>IFD_1.4</version>
</if:Protocol>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
</s:Body>
</s:Envelope>

The difference is that the namespace of the first header is "if" instead of "f".

Is there a way to do this using a custom MessageFormatter with a custom message class?

+4
source share
2 answers

, , , MessageHeader (. , , ).

, .

, , , wcf.

+2

MessageEncoder, ReadMessage WriteMessage , , xml.

0

Source: https://habr.com/ru/post/1524820/


All Articles