+49 228 5552576-0


URL Rewriting in WSDL and XML Schema

To make a call to a service a consumer only needs a WSDL document of the service. WSDL not only describes a service it also delivers the endpoint address of the service´s ports. Sometimes it is necessary to change the endpoint in a WSDL. This article describes how to rewrite URLs in WSDL and XML Schema documents.

Sometimes we don´t want direct access to a service. For monitoring or security reasons a router can be placed between consumer and service. See figure 1.
Suppose we are using a TCP gateway or a forwarding proxy for the HTTP protocol. First the consumer is requesting the WSDL of the service from the router located at the host gateway. The router is then forwarding the WSDL request to the service. The service responses with the WSDL document. Which is forwarded by the router to the consumer. The consumer reads the WSDL and looks for a suitable port for the service.

Communication without URL Rewriting

Figure1: Communication without URL Rewriting

Listening 1 shows the WSDL´s service element:

<wsdl:service name="BLZService">
          <wsdl:port name="BLZServiceSOAP11port_http" binding="tns:BLZServiceSOAP11Binding">
              <soap:address location="http://www.thomas-bayer.com:80/axis2/services/BLZService"/>
Listing 1: Service Element

The only port of the service in the listening has an endpoint address pointing to the server. The consumer uses this address to send SOAP messages and bypasses the router as illustrated in figure 1. If the router is used for a firewall the request is hopefully not routed to the service. If the router is used for monitoring the communication between the consumer and the service the messages are not monitored. In order to direct the SOAP messages through the router the router has to rewrite the endpoint URL of the service.
Rewriting means to exchange the address of the service with the address of the router. The example in figure 2 shows the rewriting of an endpoint address.

Rewriting of an Endpoint Address

Figure2: Rewriting of an Endpoint Address

The client now reads the WSDL document containing the rewritten endpoint URL pointing to the router instead of pointing to the service. If the client is sending now a request it is sent to the router as illustrated in figure 3.

Communication with URL Rewriting

Figure3: Communication with URL Rewriting

Rewriting of Schema Imports and Includes

Some WSDL documents reference external XML schema documents describing the datatypes used by the service. The schemas themselves can reference more schemas.
Figure 4 shows the import and include relationships of a sample service. The WSDL´s embedded schema is importing a schema describing business objects and one describing common objects. The schema for the common objects contains a schema describing base types.

Import/Include Graph of a WSDL

Figure4: Import/Include Graph of a WSDL

The router has to rewrite all the URLs in XML schema imports and includes also. Rewriting all the URLs causes all the messages to flow through the router as shown in Figure 5.

Rewritten of Schema Import and Include Addresses

Figure5: Rewritten of Schema Import and Include Addresses

Rewriting in Membrane Monitor

Membrane Monitor automatically rewrites all URLs in endpoint addresses, XML Schema imports and includes. The hostname used for the rewriting is the HTTP header field Host.
Internally the rewriting is done by the WSDLInterceptor component that can be configured into the message flow. If you are using Membrane Service Proxy instead of Membrane Monitor, make sure that the wsdlRewriter element is used in the proxies.xml configuration file.

Copyright © 2008-2015 predic8 GmbH
Moltkestr. 40, 53173 Bonn, Tel. +49 (228) 555 25 76-0