+49 228 5552576-0


info@predic8.com

URL Rewriting

Requires version 3.0.0 or above.

Membrane Monitor/Router can change the path URI of a request. A request to

http://router.predic8.com/blz-service?wsdl


can be rewritten to

http://www.thomas-bayer.com/axis2/services/BLZService?wsdl

We want to hide that this service is hosted by axis2. To do this we have to replace the part axis2 from the context path. The hostname is changed by the service proxy. To change the path URI you have to use an URL rewriting feature.

URL Rewriting Feature

To demonstrate how the rewriting works we present here the step by step description how to map the WSDL of the BLZService to a nicer URL.

Start Membrane Monitor and create a simple Service Proxy.

Creating a new Service Proxy

Figure1: Creating a new Service Proxy

Specify 2000 as the port number on which the router will listen.

Listen Port

Figure2: Listen Port

Than specify thomas-bayer.com as target host and 80 as target port. Next click on Finish.

Target Host and Port

Figure3: Target Host and Port

To add the URL rewriting feature do right click on the newly created service proxy in the Proxies View and choose edit. Then click onto the XMLConfiguration tab and have a look on it. An XML representation of the Service Proxy is displayied in the main text area of the tab.

Service Proxy XML Configuration

Figure4: Service Proxy XML Configuration Tab

add an URL Rewriting element to the Configuration XML so that your Proxy Service definition looks like.

      
  <serviceProxy name="" port="2000">
    <rewriter>
      <map from="^/bank/(.*)" to="/axis2/$1" />
    </rewriter>
    <target host="www.thomas-bayer.com" port="80" />
  </serviceProxy>
      
      
Listing 12: Service Proxy with URL Reqwriter

Click on OK button to apply changes and to save Service proxy configuration.

How it Works

After adding the rewriting feature the RewriteInterceptor is set for the rule. The interceptor will be called during the processing of each request and response.

Now take a closer look at the rewriter element:

      
    <rewriter>
      <map from="^/bank/(.*)" to="/axis2/$1" />
    </rewriter>
      
      
Listing 12: Service Proxy with URL Reqwriter

The interceptor is configured with one regular expression /bank/(.*) . This will match the following URIs:

/bank/services/BLZService?wsdl

/bank/services/BLZService

In the regular expression we use a group that we can reference when replacing the URI. The value to replace the URI is given by the uri attribute and is set to /axis/$1 . The $1 is the reference to the group and will contain the value matched by the group. So the above URIs will be replaced by the following:

/axis2/services/BLZService?wsdl

/axis2/services/BLZService

Test URL Rewriting

Test the monitor by opening the URL http://localhost:2000/bank/services/BLZService?wsdl in your browser. You should get the WSDL from the BLZ service.

Requesting the WSDL with a nicer URL

Figure5: Requesting the WSDL with a nicer URL

Copyright © 2008-2017 predic8 GmbH
Koblenzerstr. 65, 53173 Bonn, Tel. +49 (228) 555 25 76-0