Change Namespace WCF Envelope Prefix

I was wondering, anyway, to change the namespace prefix for a WCF SOAP request?

As you can see in the example below, The Envelope has the namespace "http://www.w3.org/2005/08/addressing" with the prefix "a". I want to change this to "foo". How can I do it. Note. I have no control over the service code. I can only create a proxy class from WSDL.

<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header> <a:Action s:mustUnderstand="1">http://www.starstandards.org/webservices/2005/10/transport/operations/MyAction</a:Action> <h:payloadManifest xmlns="http://www.starstandards.org/webservices/2005/10/transport" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="http://www.starstandards.org/webservices/2005/10/transport"> <manifest contentID="Content0" namespaceURI="http://www.starstandard.org/STAR/5" element="TESTMETHOD" version="5.2.4"></manifest> </h:payloadManifest> <h:Identity xmlns="urn:xxx/xxx/" xmlns:h="urn:xxx/xxx"> <SiteCode>XXXXXX</SiteCode> </h:Identity> <a:To>urn:xxx/xxx/Method1</a:To> <MessageID xmlns="http://www.w3.org/2005/08/addressing">XXXXX</MessageID> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> </s:Header> 
+4
source share
3 answers

This can be done on the client or server side using MessageFormatter. You can also change this with MessageEncoder, but this has a lot of problems.

This article describes how to do this on the server side using MessageFormatter, as well as the reverse side of MessageEncoder:

http://vanacosmin.ro/Articles/Read/WCFEnvelopeNamespacePrefix

What you need to do is apply the MessageFormatter client side (possibly using ApplyClientBehavior instead of ApplyDispatchBehavior). In addition, in a custom message class, you need to add your namespace as an attribute with the prefix "foo" (in the OnWriteStartEnvelope method).

Unfortunately, there is no easy way (for example, applying some attributes) that will make the necessary changes.

+2
source

WCF provides the ability to manage most of the SOAP Envelop data using messaging contracts. But I doubt that you can do something with the namespace prefix . However, you can manage the namespace.

Refer to Using Message Contracts

0
source

I do not know how to manage the prefixes that WCF uses in their standard message encoders.

I think you need to write a special message encoder if you want the message on the wire to use different prefixes.

0
source

All Articles