Archive for the ‘Monitor’ Category

JSON Beautifier

May 12, 2011 Leave a comment

Membrane Monitor 2 now features a JSON beautifier that helps to debug AJAX applications and REST resources.

JSON Formatter

JSON Formatter

Categories: Monitor Tags: , , ,

Tutorial: Mapping SOAP Operations to REST Resources

May 11, 2011 2 comments

REST 2 SOAP Mapping

In this Tutorial we will see how to use the REST2SOAPInterceptor. It will allow us to call a SOAP Web Service by using REST resource URIs. For example take a look at the BLZService at the following location:

To call the getBank operation you have to send a SOAP message like the following:

<soapenv:Envelope xmlns:soapenv=””

Now let us imagine that there is a REST resource for banks. Probably the URI to get a representation of a bank will look like this:


This mapping can be done by the REST2SOAPInterceptor without modifing the SOAP service.


First we will take a look at how the interceptor works. It is configured by a list of mappings. Each of them contains the information to map HTTP requests to SOAP operations. This allows us to map many SOAP operations with one interceptor. Finding the right mapping for a given HTTP request is done by a regular expression. Every mapping contains a regular expression that is matched against the URL of the HTTP request. The mapping which regular expression matches first is taken. With that mapping the interceptor creates a XML document from the HTTP request.

For example for the  following HTTP request

GET /bank/37050198 HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/3.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive

the interceptor will create the following XML document:

<request method="GET" http-version="1.1">
  <uri value="/bank/37050198">
    <header name="User-Agent">Jakarta Commons-HttpClient/3.1</header>
    <header name="Host"></header>

Than a  XSLT transformation is applied to the XML document. The transformation creates the SOAP message for the SOAP operation we want to call. Finally the transformed message is send to the endpoint of the SOAP service. After receiving the response the intercetor can by configured to apply another XSLT transformation to strip the SOAP envelope of the response. The service endpoint and the references to the XSLT stylesheets are defined in the mapping.

RESTfull BLZ Service

  1. Create a stylesheet called blz-httpget2soap-request.xsl. It will be used by the interceptor to create the SOAP message. It should have the following content:
    <xsl:stylesheet version=”1.0″ xmlns:xsl=””
      <xsl:template match=”/”>
        <s11:Envelope >
              <blz:blz><xsl:value-of select=”//path/component[2]“/></blz:blz>
  2. Create a stylesheet called strip-soap-envelope.xslto strip the SOAP envelope from the response. It should have the following content:
    <xsl:stylesheet version=”1.0″ xmlns:xsl=””
      <xsl:template match=”/”>
        <xsl:apply-templates select=”//s11:Body/*”/>
      <xsl:template match=”@*|node()”>
          <xsl:apply-templates select=”@*”/>
  3. Copy the stylesheets into the configuration folder of your monitor or router installation directory.
  4. Open monitor-beans.xml and add a bean for the REST2SOAP interceptor to the list of interceptors in the transport bean.
    <bean id="transport" class="com.predic8.membrane.core.transport.http.HttpTransport">
      <property name="interceptors">
          <bean class="">
            <property name="mappings">
                <entry key="/bank/.*">
                    <entry key="SOAPAction" value=""/>
              	<entry key="SOAPURL" value="/axis2/services/BLZService" />
              	<entry key="requestXSLT" value="configuration/blz-httpget2soap-request.xsl" />
              	<entry key="responseXSLT" value="configuration/strip-soap-envelope.xsl" />
  5. Start the Membrane monitor.
  6. Create a rule that listens on port 2000 and redirect requests to
  7. Open the link http://localhost:2000/bank/37050198 in your browser.
Categories: Monitor, Router