in

mscommunity.net

Interactive mscommunity.net online activities

DamirDobric

Message Addressing in WCF

This post contains few examples of the same request of one service by using of different types of addressing. For this reason I configured a custom binding
with one encoding element and one http transport element. For different tests I used different addressing methods.

Here is the sample code:

CustomBinding custBinding = new CustomBinding();

TextMessageEncodingBindingElement txtElem = new
TextMessageEncodingBindingElement();

// Here I used all supported addressing
txtElem.MessageVersion = MessageVersion.Soap11WSAddressing10;
           

custBinding.Elements.Add(txtElem);

 

HttpTransportBindingElement basicHttpBinding =
new HttpTransportBindingElement();

custBinding.Elements.Add(basicHttpBinding);


And, here is the result:

Soap11

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">

  <s:Header>

    <ActivityId CorrelationId="045e4ff1-c907-4d64-84af-fef25052683e" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">d003468d-7fad-40bd-9ffd-2a99862c9b41</ActivityId>

  </s:Header>

  <s:Body>

    <QueryMessage xmlns="cevapproduction">

      <CevapQuery xmlns:a="http://schemas.datacontract.org/2004/07/Server" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

        <a:Cijena>0</a:Cijena>

        <a:KajmakYesNo>true</a:KajmakYesNo>

      </CevapQuery>

    </QueryMessage>

  </s:Body>

</s:Envelope>

 

 

Soap11WSAddressing10

 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://www.w3.org/2005/08/addressing">

  <s:Header>

    <a:Action s:mustUnderstand="1">cevapproduction/ICevap/ImaLiCevapa</a:Action>

    <a:MessageID>urn:uuid:f2d9e6c0-80a2-44f0-a2eb-6e5aa1808712</a:MessageID>

    <ActivityId CorrelationId="95641fb0-b3f1-4e26-8038-947a06aee055" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">da1ff29d-6235-4c1b-85c8-daebf827a6fd</ActivityId>

    <a:ReplyTo>

      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>

    </a:ReplyTo>

    <a:To s:mustUnderstand="1">http://dado-nb0:8001/cevapservice/encodingsample1</a:To>

  </s:Header>

  <s:Body>

    <QueryMessage xmlns="cevapproduction">

      <CevapQuery xmlns:b="http://schemas.datacontract.org/2004/07/Server" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

        <b:Cijena>0</b:Cijena>

        <b:KajmakYesNo>true</b:KajmakYesNo>

      </CevapQuery>

    </QueryMessage>

  </s:Body>

</s:Envelope>

 

Soap11WSAddressingAugust2004

 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">

  <s:Header>

    <a:Action s:mustUnderstand="1">cevapproduction/ICevap/ImaLiCevapa</a:Action>

    <a:MessageID>urn:uuid:b047d205-2a7c-4b35-8c52-bac97960292e</a:MessageID>

    <ActivityId CorrelationId="c80c7ba7-fd39-436c-98a8-3f32f6860ba8" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">3e5025d3-afad-497b-a992-aa49dabf0be7</ActivityId>

    <a:ReplyTo>

      <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>

    </a:ReplyTo>

    <a:To s:mustUnderstand="1">http://dado-nb0:8001/cevapservice/encodingsample1</a:To>

  </s:Header>

  <s:Body>

    <QueryMessage xmlns="cevapproduction">

      <CevapQuery xmlns:b="http://schemas.datacontract.org/2004/07/Server" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

        <b:Cijena>0</b:Cijena>

        <b:KajmakYesNo>true</b:KajmakYesNo>

      </CevapQuery>

    </QueryMessage>

  </s:Body>

</s:Envelope>

 

Soap12

 

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">

  <s:Header>

    <ActivityId CorrelationId="0283f490-30e1-4759-8d26-1c4a44a14765" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">8358b1d2-b95c-4bbc-9c65-c9f2b4a29366</ActivityId>

  </s:Header>

  <s:Body>

    <QueryMessage xmlns="cevapproduction">

      <CevapQuery xmlns:a="http://schemas.datacontract.org/2004/07/Server" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

        <a:Cijena>0</a:Cijena>

        <a:KajmakYesNo>true</a:KajmakYesNo>

      </CevapQuery>

    </QueryMessage>

  </s:Body>

</s:Envelope>

 

Soap12WSAddressing10

 

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">

  <s:Header>

    <a:Action s:mustUnderstand="1">cevapproduction/ICevap/ImaLiCevapa</a:Action>

    <a:MessageID>urn:uuid:7ab8eabf-cd15-4b6c-8c23-180243cf3ccd</a:MessageID>

    <ActivityId CorrelationId="1c0e317c-52e9-4855-beff-1f27081d2306" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">99b55e02-3396-4f9e-911f-4025f3119468</ActivityId>

    <a:ReplyTo>

      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>

    </a:ReplyTo>

    <a:To s:mustUnderstand="1">http://dado-nb0:8001/cevapservice/encodingsample1</a:To>

  </s:Header>

  <s:Body>

    <QueryMessage xmlns="cevapproduction">

      <CevapQuery xmlns:b="http://schemas.datacontract.org/2004/07/Server" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

        <b:Cijena>0</b:Cijena>

        <b:KajmakYesNo>true</b:KajmakYesNo>

      </CevapQuery>

    </QueryMessage>

  </s:Body>

</s:Envelope>

 

Soap12WSAddressingAugust2004

 

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">

  <s:Header>

    <a:Action s:mustUnderstand="1">cevapproduction/ICevap/ImaLiCevapa</a:Action>

    <a:MessageID>urn:uuid:23bda306-55e5-48c3-9244-9f1a6616bc27</a:MessageID>

    <ActivityId CorrelationId="b6d711dc-2368-4630-bbc6-8e67f1531de6" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">b92455ec-d044-4a71-b893-87aa039354b6</ActivityId>

    <a:ReplyTo>

      <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>

    </a:ReplyTo>

    <a:To s:mustUnderstand="1">http://dado-nb0:8001/cevapservice/encodingsample1</a:To>

  </s:Header>

  <s:Body>

    <QueryMessage xmlns="cevapproduction">

      <CevapQuery xmlns:b="http://schemas.datacontract.org/2004/07/Server" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

        <b:Cijena>0</b:Cijena>

        <b:KajmakYesNo>true</b:KajmakYesNo>

      </CevapQuery>

    </QueryMessage>

  </s:Body>

</s:Envelope>

 

Read the complete post at http://developers.de/blogs/damir_dobric/archive/2009/06/28/message-addressing-in-wcf.aspx

Published lip 28 2009, 11:44 by anonymous
Filed under:
Powered by Community Server (Commercial Edition), by Telligent Systems