.NET Framework Bookmark and Share   
 index > Windows Communication Foundation > Defining xmlns in SOAP header, config or code?
 

Defining xmlns in SOAP header, config or code?

I'm partway through what I believe is a solution to getting a namespace defined for a custom header field in my SOAP envelope but wanted to ensure that I wasn't missing a more obvious solution. I'm currently working on plugging in the behavior for a custom class that implements DataContractSerializerOperationBehaviour and writes the required xmlns and prefix element.

Is there a configuration solution to this requirement? Below are fragments for what is currently generate and what is expected.

Current snippet

Thanks in advance for any assistance.

Regards,
Derek.

Expected snippet

  <soapenv:Header>
    <td:System xmlns:td="http://td.webservice.lambda.ca" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
        <td:SystemId>LDC</td:SystemId>
    </td:System>


<s:Header>
    <System xmlns="http://td.webservice.lambda.ca">
        <SystemId>LDC</SystemId>
    </System>

Derek Tinney
So the second is not what you want? The only difference in XML terms in the lack of the actor and MustUnderstand the rest of the XML is the same - just expressed differently

Or are you saying you need the same prefixes in the serialized header and XML equivelence is not enough?
Richard Blewett, thinktecture - http://www.dotnetconsult.co.uk/weblog2
Twitter: richardblewett
Richard Blewett
Hi Derek,

Please refer to this article. You can write data contract to see whether it satisfies your requirement. Or you can give more detailed description so that we can help you here.
http://msdn.microsoft.com/en-us/magazine/cc163569.aspx
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong
Thanks for the assistance. I was looking for guidance as to whether I should be pursuing a config vs. code solution to getting those namespaces defined. In the end it was a coding solution whereby I created a new class implementing MessageHeader.

override OnWriteStartHeader to get the mustUnderstand attribute written.
override OnWriteHeaderContents with a custom header defining its' td namespace

Added that via a new MessageInspector and behaviour

The following article was most helpful.


Regards,
Derek.
Derek Tinney

You can use google to search for other answers

Custom Search

More Threads

• Length of return data with WCF ??
• WebInvoke Method +WCF+returning 415-Missing content type
• Multiple service contract using the same data contract
• TcpClient as Calling Client to WCF Service
• I have a problem with transfering complex object
• Hosting WCF in Windows Server 2003 with Visual Studio 2008 SP1.
• Orcas Beta1 Xbap partial trust call to wcf service
• how is byte array serialized under DataContractSerializer?
• WCF TimeoutException / CommunicationException when impersonating only
• WCF Service methods returning results to wrong clients?