WCF: How to apply ws-addressing

So I ran into a situation where I needed to apply ws-addressing and a specific SOAP version to a web service. How does one do this? Well, in short, you create a custom binding, bind your endpoint to it, then set the textMessageEncoding property. Here is the simplified config:

 

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

    <system.serviceModel>

        <bindings>

            <customBinding>

                <binding name="BindingSoap12Address10">

                    <textMessageEncoding />

                    <httpTransport />

                </binding>

                <binding name="BindingSoap11Address10">

                    <textMessageEncoding messageVersion="Soap11WSAddressing10" />

                    <httpTransport />

                </binding>

                <binding name="BindingSoap11Address2004">

                    <textMessageEncoding messageVersion="Soap11WSAddressingAugust2004" />

                    <httpTransport />

                </binding>

                <binding name="BindingSoap12Address2004">

                    <textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" />

                    <httpTransport />

                </binding>

            </customBinding>

        </bindings>

        <behaviors>

            <serviceBehaviors>

                <behavior name="mexBehavior">

                    <serviceMetadata httpGetEnabled="true" httpGetUrl="metaData" />

                </behavior>

            </serviceBehaviors>

        </behaviors>

        <services>

            <service behaviorConfiguration="mexBehavior" name="WcfConsumer.MyService">

                <endpoint address="" binding="customBinding"

                          bindingConfiguration="BindingSoap12Address2004"

                          name="HttpSoap12Address2004" contract="WcfConsumer.IMyContract" />

                <host>

                    <baseAddresses>

                        <add baseAddress="http://localhost:2122/MyService" />

                    </baseAddresses>

                </host>

            </service>

        </services>

    </system.serviceModel>

</configuration>

 

It’s a little more readable in the tool (C:Program FilesMicrosoft SDKsWindowsv6.0BinSvcConfigEditor.exe – part of the .NET 3.0 SDK, I think?):

 

screenshot1

 

Where MessageVersion has these for options:

 

 screenshot2

 

Soap11 and SOAP 1.1 – and Addressing10 means ws-Addressing 1.0 where AddressingAugust2004 means the old 2004/08 standard. So obviously from this dropdown, you have the various combinations of which SOAP version and which ws-addressing version. There it is.

Posted in .NET 3.5, Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives
Categories

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 5 other followers

%d bloggers like this: