Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Figure 1: Envelope Wrapper EIP

Example

...

scenario

This example scenario receives a message with application data wrapped inside an envelope, unwraps the message and sends it to a specific endpoint. The sender sends the request inside a SOAP envelop. Once the ESB receives the envelop, it unwraps the envelop and sends it as a Plain Old XML (POX) request to the sample back-end Axis2 server.

Implementing the Example Scenario in WSO2 ESB

Getting Started

The diagram below depicts how to simulate the example scenario using the WSO2 ESB.

...

Info
titleAlternative Implementation

An alternative implementation of this EIP is to have the wrapping be done by the Address Endpoint from one envelope format to another (for example wrapping a SOAP 1.1 envelope in a SOAP 1.2 envelope).

Environment

...

setup

...

  1. Download an install the WSO2 ESB from http://wso2.com/products/enterprise-service-bus. For a list of prerequisites and step-by-step installation instructions, refer to Getting Started in the WSO2 ESB documentation.

...

  1. Start the sample Axis2 server. For instructions, refer to section ESB Samples Setup - Starting Sample Back-End Services in the WSO2 ESB documentation.

ESB

...

configuration

3. Start the ESB server and log into its management console UI (https: //localhost:9443/carbon). In the management console, navigate to Main Menu, click Service Bus and then Source View. Next, copy and paste the following configuration, which helps you explore the example scenario, to the source view. 

Anchor
step3
step3

Code Block
languagehtml/xml
linenumberstrue
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
   <proxy name="EnvelopeUnwrapProxy"
          transports="https http"
          startOnLoad="true">
      <target>
         <endpoint>
            <address uri="http://localhost:9000/services/SimpleStockQuoteService"
                     format="pox"/>
         </endpoint>
         <outSequence>
            <send/>
         </outSequence>
      </target>
      <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
   </proxy>
   <sequence name="fault">
      <log level="full">
         <property name="MESSAGE" value="Executing default &#34;fault&#34; sequence"/>
         <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
         <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
      </log>
      <drop/>
   </sequence>
   <sequence name="main">
      <send/>
   </sequence>
</definitions>

Simulating the

...

sample scenario

4.
  1. Send the following request using a client like SOAP UI, and monitor the message using TCPMon.
     

    Code Block
    languagehtml/xml
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">
       <soapenv:Header/>
       <soapenv:Body>
          <ser:getQuote>     
             <ser:request>           
                <xsd:symbol>Foo</xsd:symbol>
             </ser:request>        
          </ser:getQuote>
       </soapenv:Body>
    </soapenv:Envelope>
  2. Notice that the request data is inside a SOAP envelope. When the request was monitored through TCPMon before it was sent to the ESB, it was structures as follows.

    Code Block

...

languagehtml/xml
  1. POST /services/EnvelopeUnwrapProxy HTTP/1.1 
    Accept-Encoding: gzip,deflate 
    Content-Type: text/xml;charset=UTF-8 
    SOAPAction: "urn:getQuote" 
    Content-Length: 385 
    Host: 127.0.0.1:8281 
    Connection: Keep-Alive 
    User-Agent: Apache-HttpClient/4.1.1 (java 1.5) 
     
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">
       <soapenv:Header/>
       <soapenv:Body>
          <ser:getQuote>     
             <ser:request>           
                <xsd:symbol>Foo</xsd:symbol>
             </ser:request>        
          </ser:getQuote>
       </soapenv:Body>
    </soapenv:Envelope>
  2. The request sent to the back-end Axis2 server has following structure.

    Code Block

...

...

  1. POST /services/SimpleStockQuoteService HTTP/1.1 
    Content-Type: application/xml; charset=UTF-8 
    Accept-Encoding: gzip,deflate 
    SOAPAction: urn:getQuote 
    Transfer-Encoding: chunked 
    Host: localhost:9000 
    Connection: Keep-Alive 
    User-Agent: Synapse-HttpComponents-NIO 
     
    e0 
    <ser:getQuote xmlns:ser="http://services.samples">     
             <ser:request>           
                <xsd:symbol xmlns:xsd="http://services.samples/xsd">Foo</xsd:symbol>
             </ser:request>        
          </ser:getQuote> 
    0 

    This means that the SOAP envelope was removed by the ESB.

...

How the

...

implementation works

Let's investigate the elements of the ESB configuration in detail. The line numbers below are mapped with the ESB configuration illustrated in step 3 above.

  • address [line 8 in ESB config] - The endpoint address contains the attribute format='pox', which makes the ESB convert incoming requests to Plain Old XML. Other supported formats for wrapping include soap11, soap12 and get. For more information, refer to the Address Endpoint mediator.  

...

hiddentrue

...