Petals-BC-SOAP 4.1.x

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (8)

View Page History
* Expose JBI Services as SOAP Web Services
* Expose SOAP Web Services as JBI Services
* Expose JBI Services as RESTful Web Services
* Expose RESTful Web Services as JBI Services
* Handle SOAP attachments (MTOM). The attachments of the incoming SOAP message are placed into the JBI message as attachments; the JBI attachments are placed in the outgoing SOAP message as attachments.

{center}{*}Configuration of a Service Unit to provide a service (SOAP)*{center}
{table-plus:columnAttributes=,,style="text-align:center;",style="text-align:center;"}









|| Parameter || Description || Default || Required ||
| soap-version | The SOAP version used to create SOAP messages. \\
{petalslink}
{table-plus:columnAttributes=,,style="text-align:center;",style="text-align:center;"}









|| Parameter || Description || Default || Required ||
| wsa-to | Default address of the external Web Service to send JBI messages to. | \- | No |
{center}{*}Configuration of a Service Unit to consume a service (SOAP)*{center}
{table-plus:columnAttributes=,,style="text-align:center;",style="text-align:center;"}









|| Parameter || Description || Default || Required ||
| service-name | Web Service name to expose. | \- | No |
{petalslink}
{table-plus:columnAttributes=,,style="text-align:center;",style="text-align:center;"}









|| Parameter || Description || Default || Required ||
| service-parameters | Additional XML configuration for created Axis2 service as CDATA, same as the Axis2 services.xml file one. | | No |
* The META-INF/jbi.xml descriptor file as described above

h1. Provide a REST Service access in the ESB

In provide mode, the component exposes an external Web Service in the JBI environment to send REST requests to the external Web Service.

{warning:title=Warning}
This feature is currently only supported with the MEP InOut.
{warning}

h2. Usage

The petals-bc-soap component can expose an external Web Service as a JBI service endpoint by deploying a Service Unit on it:

{center}

!petals-bc-soap-x.x-provider..png|border=1,width=500,height=285!
*Provides an external Web Service as a JBI service*
{center}

When a message is received on a REST linked endpoint from the JBI environment, it is transformed into a REST message and sent to the Web Service. The address of the Web Service to send the REST message to is defined in the address extension of the deployed Service Unit.

The REST message is created like this:
* The JBI message payload and the exchange operation are used to create the HTTP body
* The address extension is used to create the REST URI
* The rest-http-method extension is used to choose the HTTP method (if it is not defined, the method POST is used)

The external Web Service is called and the REST response is processed and returned to the JBI environment.

The address extension can be configured with placeholders. The placeholder will be replaced by the result of the XPath expression defined inside of the placeholder. The XPath expression is performed on the content of the incoming JBI message. The placeholders will be replaced in the address extension to build the final URI according to the result of the XPath expression.

For example the following JBI message:
{code:lang=xml}
<weat:getWeather xmlns:weat="http://petals.ow2.org/services/weather">
<citycode>FRXX0099</citycode>
<unit>c</unit>
</weat:getWeather>
{code}
is associated with the address parameter value:
{code}
http://weather.yahooapis.com/forecastrss?p={/*[localname()='getWeather'][1]/*[local-name()='citycode']
[1]}&amp;u={/*[local-name()='getWeather'][1]/*[local-name()='unit'][1]}
{code}
and produces the URI [http://weather.yahooapis.com/forecastrss?p=FRXX0099&u=c].

The JBI message response returned by the Yahoo Weather REST service corresponding to the previous URI is:
{code:lang=xml}
<rss version="2.0" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<channel>
<title>Yahoo! Weather - Toulouse, FR</title>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Toulouse__FR/*http://weather.yahoo.com/forecast/
FRXX0099_c.html</link>
<description>Yahoo! Weather for Toulouse, FR</description>
<language>en-us</language>
<lastBuildDate>Thu, 06 Mar 2008 3:00 pm CET</lastBuildDate>
<ttl>60</ttl>
<yweather:location city="Toulouse" country="FR" region=""/>
<yweather:units distance="km" pressure="mb" speed="kph" temperature="C"/>
<yweather:wind chill="3" direction="310" speed="37"/>
<yweather:atmosphere humidity="37" pressure="0" rising="0" visibility="999"/>
<yweather:astronomy sunrise="7:22 am" sunset="6:50 pm"/>
<image>
<title>Yahoo! Weather</title>
<width>142</width>
<height>18</height>
<link>http://weather.yahoo.com/</link>
<url>http://l.yimg.com/us.yimg.com/i/us/nws/th/main_142b.gif</url>
</image>
<item>
<title>Conditions for Toulouse, FR at 3:00 pm CET</title>
<geo:lat>43.61</geo:lat>
<geo:long>1.45</geo:long>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Toulouse__FR/*http://weather.yahoo.com/forecast/
FRXX0099_c.html</link>
<pubDate>Thu, 06 Mar 2008 3:00 pm CET</pubDate>
<yweather:condition code="28" date="Thu, 06 Mar 2008 3:00 pm CET" temp="8" text="Mostly
Cloudy"/>
<description>
<![CDATA[<img src="http://l.yimg.com/us.yimg.com/i/us/we/52/28.gif" /><br />
<b>Current Conditions:</b><br />
Mostly Cloudy, 8 C<BR /><BR />
<b>Forecast:</b><BR />
Thu - Mostly Cloudy. High: 10 Low: 4<br />
Fri - Cloudy. High: 10 Low: 4<br />
<br />
<a
href="http://us.rd.yahoo.com/dailynews/rss/weather/Toulouse__FR/*http://weather.yahoo.com/forecast/
FRXX0099_c.html">Full Forecast at Yahoo! Weather</a><BR/>
(provided by The Weather Channel)<br/>]]>
</description>
<yweather:forecast code="27" date="06 Mar 2008" day="Thu" high="10" low="4" text="Mostly
Cloudy"/>
<yweather:forecast code="26" date="07 Mar 2008" day="Fri" high="10" low="4" text="Cloudy"/>
<guid isPermaLink="false">FRXX0099_2008_03_06_15_0_CET</guid>
</item>
</channel>
</rss>
{code}

h2. Configuration

h3. Service Unit descriptor

An example of a Service Unit descriptor that provides a REST service:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
xmlns:generatedNs="http://petals.ow2.org/GenericREST/"
xmlns:jbi="http://java.sun.com/xml/ns/jbi"
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
xmlns:soap="http://petals.ow2.org/components/soap/version-4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<jbi:services binding-component="true">

<jbi:provides
interface-name="generatedNs:RestInterface"
service-name="generatedNs:YahooWeather"
endpoint-name="YahooWeatherEndpoint">

<!-- CDK specific elements -->
<petalsCDK:timeout>30000</petalsCDK:timeout>
<petalsCDK:validate-wsdl>true</petalsCDK:validate-wsdl>
<petalsCDK:forward-security-subject>false</petalsCDK:forward-security-subject>
<petalsCDK:forward-message-properties>false</petalsCDK:forward-message-properties>
<petalsCDK:forward-attachments>false</petalsCDK:forward-attachments>
<petalsCDK:wsdl>RestService.wsdl</petalsCDK:wsdl>

<!-- Component specific elements -->
<soap:address>http://weather.yahooapis.com/forecastrss?p={/*[local-name()='getWeather'][1]/*[local-name()='citycode'][1]}&amp;u={/*[local-name()='getWeather'][1]/*[local-name()='unit'][1]}</soap:address>
<soap:mode>REST</soap:mode>
</jbi:provides>
</jbi:services>
</jbi:jbi>
{code}

{include:0 CDK SU Provide Configuration}
\\
{center}{*}Configuration of a Service Unit to provide a service (REST)*{center}
{table-plus:columnAttributes=,,style="text-align:center;",style="text-align:center;"}



|| Parameter || Description || Default || Required ||
| address | Address of the external Web Service to send JBI messages to. | \- | Yes |
| mode | The mode to be used to send SOAP message to the specified address. \\
Possible values are: SOAP for basic Web Service calls, JSON for JSON service calls and REST for REST service calls. | SOAP | Yes |
| rest-http-method | The HTTP method to be used in REST mode. \\
Possible values are: GET for the HTTP method GET, POST for the HTTP method POST, PUT for the HTTP method PUT and DELETE for the HTTP method DELETE. | POST | No |
{table-plus}


{petalslink}
{table-plus:columnAttributes=,,style="text-align:center;",style="text-align:center;"}



|| Parameter || Description || Default || Required ||
| wsa-to | Default address of the external Web Service to send JBI messages to. It is the same use than soap:address for the REST mode and it is overridden by soap:address if the both are specified. | | No |
{table-plus}
{petalslink}

h3. Service Unit content

The Service Unit has to contain the following elements, packaged in an archive:
* The META-INF/jbi.xml descriptor file as described above
* A "generic" WSDL:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
name="RestService"
targetNamespace="http://petals.ow2.org/GenericREST/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://petals.ow2.org/GenericREST/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">

<wsdl:types>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://petals.ow2.org/GenericREST/"
elementFormDefault="qualified"
targetNamespace="http://petals.ow2.org/GenericREST/"
version="1.0">

<xs:element name="delete" type="tns:delete" />
<xs:element name="deleteResponse" type="tns:deleteResponse" />
<xs:element name="get" type="tns:get" />
<xs:element name="getResponse" type="tns:getResponse" />
<xs:element name="post" type="tns:post" />
<xs:element name="postResponse" type="tns:postResponse" />
<xs:element name="put" type="tns:put" />
<xs:element name="putResponse" type="tns:putResponse" />

<xs:complexType name="delete">
<xs:sequence />
</xs:complexType>
<xs:complexType name="deleteResponse">
<xs:sequence>
<xs:element minOccurs="0" name="DeleteOutParam" type="xs:anyType" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="get">
<xs:sequence />
</xs:complexType>
<xs:complexType name="getResponse">
<xs:sequence>
<xs:element minOccurs="0" name="GetOutParam" type="xs:anyType" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="put">
<xs:sequence>
<xs:element minOccurs="0" name="PutInParam" type="xs:anyType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="putResponse">
<xs:sequence>
<xs:element minOccurs="0" name="PutOutParam" type="xs:anyType" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="post">
<xs:sequence>
<xs:element minOccurs="0" name="PostInParam" type="xs:anyType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="postResponse">
<xs:sequence>
<xs:element minOccurs="0" name="PostOutParam" type="xs:anyType" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>

<wsdl:message name="get">
<wsdl:part name="parameters" element="tns:get" />
</wsdl:message>
<wsdl:message name="putResponse">
<wsdl:part name="parameters" element="tns:putResponse" />
</wsdl:message>
<wsdl:message name="deleteResponse">
<wsdl:part name="parameters" element="tns:deleteResponse" />
</wsdl:message>
<wsdl:message name="post">
<wsdl:part name="parameters" element="tns:post" />
</wsdl:message>
<wsdl:message name="put">
<wsdl:part name="parameters" element="tns:put" />
</wsdl:message>
<wsdl:message name="postResponse">
<wsdl:part name="parameters" element="tns:postResponse" />
</wsdl:message>
<wsdl:message name="delete">
<wsdl:part name="parameters" element="tns:delete" />
</wsdl:message>
<wsdl:message name="getResponse">
<wsdl:part name="parameters" element="tns:getResponse" />
</wsdl:message>

<wsdl:portType name="RestInterface">
<wsdl:operation name="delete">
<wsdl:input name="delete" message="tns:delete" />
<wsdl:output name="deleteResponse" message="tns:deleteResponse" />
</wsdl:operation>

<wsdl:operation name="get">
<wsdl:input name="get" message="tns:get" />
<wsdl:output name="getResponse" message="tns:getResponse" />
</wsdl:operation>

<wsdl:operation name="put">
<wsdl:input name="put" message="tns:put" />
<wsdl:output name="putResponse" message="tns:putResponse" />
</wsdl:operation>

<wsdl:operation name="post">
<wsdl:input name="post" message="tns:post" />
<wsdl:output name="postResponse" message="tns:postResponse" />
</wsdl:operation>
</wsdl:portType>

<wsdl:binding name="GenericRestServiceSoapBinding" type="tns:RestInterface">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />

<wsdl:operation name="delete">
<soap:operation soapAction="" style="document" />
<wsdl:input name="delete">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="deleteResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>

<wsdl:operation name="get">
<soap:operation soapAction="" style="document" />
<wsdl:input name="get">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="getResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>

<wsdl:operation name="put">
<soap:operation soapAction="" style="document" />
<wsdl:input name="put">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="putResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>

<wsdl:operation name="post">
<soap:operation soapAction="" style="document" />
<wsdl:input name="post">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="postResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>

<wsdl:service name="YahooWeather">
<wsdl:port name="YahooWeatherEndpoint" binding="tns:GenericRestServiceSoapBinding">
<soap:address location="http://localhost:9090/GenericRestEndpoint" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
{code}

h1. Exposing an internal JBI service endpoint as a REST Service

In consumer mode, the component exposes an internal JBI service outside the bus to transfer incoming REST requests to the internal service.

h2. Usage

The petals-bc-soap component can listen incoming REST messages and send messages to a JBI service endpoint by deploying a Service Unit on it. The component consumes the JBI service:

{center}
!petals-bc-soap-x.x-consumer.png|border=1,width=500,height=285!
*Consumes a JBI service on a REST message*
{center}

The service-name Service Unit extension value will be used as Axis2 service name.

When a REST message is handled by the component, it is transformed into a JBI Message and sent to the JBI service endpoint configured in the Service Unit. The JBI message is created like this:
* The JBI operation is created from the incoming REST query. A URL like http://<host>:<port>/petals/services/<service-name>/operation?param1=value1&param2=value2 produces the 'operation' JBI operation.
* The JBI payload depends on the HTTP method used in the incoming request:
** GET: The JBI message is created from the URL parameters
** POST/PUT/DELETE: The JBI message is copied from the HTTP body (only XML contents are supported)

By default, the component is configured to handle URI with the [http://localhost:8084/petals/services/]<service-name> pattern (this URI can be configured in the [SOAP component configuration|Petals-BC-SOAP 4.1.x#componentConfiguration]). It also handles ?wsdl calls; the WSDL description is retrieved from the endpoint and sent back to the consumer.

h2. Configuration

h3. Service Unit descriptor

An example of a Service Unit descriptor that consumes a REST service:
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
xmlns:generatedNs="http://petals.ow2.org/"
xmlns:jbi="http://java.sun.com/xml/ns/jbi"
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5"
xmlns:soap="http://petals.ow2.org/components/soap/version-4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<jbi:services binding-component="true">

<jbi:consumes
interface-name="generatedNs:IntegrationService"
service-name="generatedNs:IntegrationService"
endpoint-name="IntegrationServiceSOAP">

<!-- CDK specific elements -->
<petalsCDK:timeout>30000</petalsCDK:timeout>
<petalsCDK:mep xsi:nil="true" />

<!-- Component specific elements -->
<soap:address>RESTService</soap:address>
<soap:mode>REST</soap:mode>
<soap:rest-add-namespace-uri>http://petals.ow2.org/</soap:rest-add-namespace-uri>
<soap:rest-add-namespace-prefix>ns1</soap:rest-add-namespace-prefix>
</jbi:consumes>
</jbi:services>
</jbi:jbi>
{code}

{include:0 CDK SU Consume Configuration}
\\
{center}{*}Configuration of a Service Unit to consume a service (REST)*{center}
{table-plus:columnAttributes=,,style="text-align:center;",style="text-align:center;"}



|| Parameter || Description || Default || Required ||
| service-name | Web Service name to expose. | \- | No |
| mode | The mode to be used to receive messages. \\
Possible values are: SOAP for basic Web Service messages, JSON for JSON service messages and REST for REST service messages. | SOAP | Yes |
| http-services-redirection | HTTP redirection alias(es) for exposed Web Service. | \- | No |
| address | Same as service-name. \\ {warning:title=Warning}This parameter must not be used any more. service-name must be used.{warning} | \- | No |
| {anchor:rest-add-namespace-uri}rest-add-namespace-uri | The namespace URI to be used in the the generated JBI message payload (cf [rest-add-namespace-prefix extension|petalsesb:Petals-BC-SOAP 4.x#rest-add-namespace-prefix] for the example). | \- | No |
| {anchor:rest-add-namespace-prefix}rest-add-namespace-prefix | The namespace prefix to be used in the the generated JBI message payload (used when [rest-add-namespace-uri extension|petalsesb:Petals-BC-SOAP 4.x#rest-add-namespace-uri] is defined). \\
Suppose that the XML message obtained from the URL parameters or from the HTTP body is:
{code:lang=xml}
<myOperation>
<param1>value1</param1>
<param2>value2</param2>
</myOperation>
{code} \\
With rest.add-namespace-uri parameter set to 'http://petals.ow2.org/sample' and rest.add-namespace-prefix parameter set to 'ns1', the JBI message is like:
{code:lang=xml}
<ns1:myOperation xmlns:ns1="http://petals.ow2.org/sample">
<ns1:param1>value1</ns1:param1>
<ns1:param2>value2</ns1:param2>
</ns1:myOperation>
{code} | soapbc | No |
| rest-remove-prefix-on-response | A list of NS prefixes to remove from the JBI message response (Coma Separated Values) \\
Suppose that the JBI service returns a JBI response like:
{code:lang=xml}
<ns1:Response xmlns:ns1="http://petals.ow2.org/sample1"
xmlns:ns2="http://petals.ow2.org/sample2"
xmlns:ns3="http://petals.ow2.org/sample3">
<ns1:param1>value1</ns1:param1>
<ns2:param2>value2</ns2:param2>
<ns3:param3>value3</ns3:param3>
</ns1:Response>
{code} \\
If the parameter is set to 'ns1,ns2', the message returned to the REST service consumer is:
{code:lang=xml}
<Response xmlns:ns1="http://petals.ow2.org/sample1"
xmlns:ns2="http://petals.ow2.org/sample2"
xmlns:ns3="http://petals.ow2.org/sample3">
<param1>value1</param1>
<param2>value2</param2>
<ns3:param3>value3</ns3:param3>
</Response>
{code} \\
If the parameter is set to '*', the message returned to the REST service consumer is:
{code:lang=xml}
<Response xmlns:ns1="http://petals.ow2.org/sample1"
xmlns:ns2="http://petals.ow2.org/sample2"
xmlns:ns3="http://petals.ow2.org/sample3">
<param1>value1</param1>
<param2>value2</param2>
<param3>value3</param3>
</Response>
{code} | \- | No |
{table-plus}

{petalslink}
{table-plus:columnAttributes=,,style="text-align:center;",style="text-align:center;"}



|| Parameter || Description || Default || Required ||
| service-parameters | Additional XML configuration for created Axis2 service as CDATA, same as the Axis2 services.xml file one. | \- | No |
| modules | A list of Axis2 modules names to engage (separated by comas). | \- | No |
{table-plus}
{petalslink}

h3. Service Unit content

The Service Unit has to contain the following elements, packaged in an archive:
* The META-INF/jbi.xml descriptor file as described above

h1. SOAP over JMS




|| Parameter || Description || Default || Required ||
| http-port | HTTP port of the Jetty embedded server \\ | 8084 | No |