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=”http://schemas.xmlsoap.org/soap/envelope/”

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
Host: www.thomas-bayer.com
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">www.thomas-bayer.com</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=”http://www.w3.org/1999/XSL/Transform”
      <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=”http://www.w3.org/1999/XSL/Transform”
      <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="com.predic8.membrane.core.interceptor.rest.REST2SOAPInterceptor">
            <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 thomas-bayer.com:80.
  7. Open the link http://localhost:2000/bank/37050198 in your browser.
Categories: Monitor, Router

Announcement: Upcoming Version 2.0.0 featuring REST and JSON


a new major version of the Membrane Monitor and Router will be released. We reworked the core of the router to provide a significantly increased performance and support for REST resources and JSON. Some of the highlights are:

  • A JSON beautifier that formats JSON messages in the Monitor
  • Gateway functionality that bridges between SOAP Web Services and REST resources
  • A XSLTransformer interceptor
  • An improved API that makes it easier to integrate the HTTP router into own Java programs.
  • Lots of minor bug fixes
  • An performance optimized core that can handle hundreds of concurrent connections with just 6MB of heap memory.
  • A JBoss service that makes it possible to deploy the HTTP/SOAP router into a JBoss server.
  • A validator that validates SOAP messages against WSDL definitions and XML Schemas
  • Improved connection handling that reduces the number of used sockets.

We are doing the final tests and hope that the version 2.0.0 will be available for download in a couple of days.


Categories: General