This documentation is archived and is not being maintained.

Configuring a SOAP Message Router with WSE

WSE can act as a SOAP router that intercepts SOAP messages sent to a specific URL. It can then reroute or delegate the SOAP messages to another Web server. This allows a client application to always send SOAP messages to one endpoint that is hosting WSE router; the router can then determine which Web server should handle a particular SOAP message. There are two basic steps to configuring WSE router:

  1. Configure the WSE HTTP handler to run for a Web application.
  2. Configure a referral cache, which contains the URLs a SOAP message should be rerouted to.

Configuring the WSE HTTP handler to run for a Web application

  • For the Web application that is hosting the SOAP router, include an <add> Element for <httpHandlers> (WSE for Microsoft .NET) element in the <httpHandlers> section of the Web.config file.
    Client applications can then send SOAP messages to any file with an .asmx extension within that Web application, and the WSE router will delegate the SOAP message to the URL specified in the referral cache.
    The following code example configures the WSE HTTP handler to run for any SOAP requests that come in for files with an .asmx extension. The .asmx extension is the extension used by Web services created using ASP.NET. If, for example, the base URL for the Web application is http://www.contoso.com/MyWebApplication and a file resides in that folder with a name SumService.asmx, a SOAP request sent to http://www.contoso.com/MyWebApplication/SumService.asmx is rerouted to the URL specified in the referral cache.
    Note:
    The type attribute of the <add> Element for <httpHandlers> (WSE for Microsoft .NET) must be on one line, even though the following example shows it split across multiple lines for readability.

    <configuration>
       <system.web>
          <httpHandlers>
             <add verb="*" path="*.asmx"
                  type="Microsoft.Web.Services2.Messaging.SoapHttpRouter, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          </httpHandlers>
       </system.web>
    </configuration>
    
    Note:
    All SOAP requests that come in for files with an .asmx extension for this Web application must have an entry in the referral cache or a SOAP fault will be returned to the client application.

Configuring a referral cache

  1. Add a <section> Element (WSE for Microsoft .NET) element to the <configuration> section for the Web.config file that affects the Web service. This adds the microsoft.web.services2 configuration section handler for this configuration file.
    The following code example shows how to add the microsoft.web.services2 configuration section handler.
    <configuration>
       <configSections>
          <section name="microsoft.web.services2"
                   type="Microsoft.Web.Services2.Configuration.WebServicesConfiguration, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
       </configSections>
    </configuration>
    
  2. Add a <referralCache> entry to the Web.config file hosting the Web service.
    Note:
    It is strongly recommended that the referral cache be stored in a file with a .config extension. Failure to do so may allow users to retrieve the contents of the referral cache by navigating to the file from a Web browser.

    The following code example specifies that the referral cache for the Web application affected by the Web.config file is a file named referralCache.config in the root folder of the Web application.
    <configuration>
        <microsoft.web.services2>
            <referral>
                <cache name="referralCache.config" />
            </referral>
        </microsoft.web.services2>
    </configuration>
    
    If the referral cache does not exist, an empty referral cache is created.
  3. Add entries to the referral cache that specify where SOAP requests are rerouted.
    The referral cache is an XML file with an <r:referrals> element that contains 0 or more <r:ref> elements. Each <r:ref> element contains subelements that describe a prospective incoming URL and where it should be rerouted. The incoming URL is specified in an <r:for> element and the URL to reroute the SOAP message is specified in an <r:go> element.
    The following code example represents a referral cache that reroutes SOAP requests sent to the URL http://www.contoso.com/MyWebApplication/math.asmx to the URL http://www.cohowinery.com/MyWebApplication/math.asmx.
    <?xml version="1.0" ?>
    <r:referrals
        xmlns:r="http://schemas.xmlsoap.org/ws/2001/10/referral">
        <r:ref>
        <r:for>
           <r:exact>http://www.contoso.com/MyWebApplication/math.asmx
           </r:exact>
        </r:for>
        <r:if />
        <r:go>
            <r:via>http://www.cohowinery.com/MyWebApplication/math.asmx
            </r:via>
        </r:go>
        <r:refId>uuid:fa469956-0057-4e77-962a-81c5e292f2ae</r:refId>
        </r:ref>
    </r:referrals>
    

See Also

Show: