
The component will create a JBI message depending on the http-method used in the incoming request :
* GET : A JBI message is created from the URL parameters
* POST/PUT/DELETE : The incoming XML message is used to create the JBI message.
In all the cases the namespaces are added to the JBI message if they are specified in the Service Unit configuration.
The JBI operation is created from the incoming REST query. The operation is extracted from the URL. A URL like {{http://<host>:<port>/petals/services/RESTService/operation?param1=value1¶m2=value2}} will produce the '{{operation}}' JBI operation.
h2. Samples
h3. Provide mode
In this sample, we are going to provide the Yahoo Weather Service ([http://developer.yahoo.com/weather/|http://developer.yahoo.com/weather/]) as JBI Service inside the JBI environment. It is possible by configuring a Service Unit in provider mode :
{code:lang=xml}
<?xml version="1.0" encoding="UTF-8"?>
<jbi:jbi version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jbi="http://java.sun.com/xml/ns/jbi
xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-4.0"
xmlns:soap="http://petals.ow2.org/components/soap/version-3.1"
xmlns:sample="http://petals.ow2.org/soap/sample">
<!-- Import a Service into PEtALS or Expose a PEtALS Service => use a BC. -->
<jbi:services binding-component="true">
<!-- Import a Service into PEtALS => provides a Service. -->
<jbi:provides
interface-name="sample:YahooWeatherInterface"
service-name="sample:YahooWeatherService"
endpoint-name="YahooWeatherEndpoint">
<!-- CDK specific fields -->
<petalsCDK:mep xsi:nil="true"/>
<!-- WSDL file -->
<petalsCDK:wsdl>Weather.wsdl</petalsCDK:wsdl>
<!-- SOAP specific fields -->
<soap:address>
http://weather.yahooapis.com/forecastrss?p={/*[local-name()='getWeather'][1]/*[
localname()='citycode'][1]}&u={/*[local-name()='getWeather'][1]/*[local-name()='unit'][1]}
</soap:address>
<!-- The previous address has been formatted for display purpose -->
<soap:mode>REST</soap:mode>
<soap:rest-http-method>GET</soap:rest-http-method>
</jbi:provides>
</jbi:services>
</jbi:jbi>
{code}
When receiving a JBI message on the activated JBI endpoint, the final address will be built from the JBI message payload.
\\
For example if 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 :
{noformat}
http://weather.yahooapis.com/forecastrss?p={/*[localname()='getWeather'][1]/*[local-name()='citycode']
[1]}&u={/*[local-name()='getWeather'][1]/*[local-name()='unit'][1]}
{noformat}
and produces the URI {{http://weather.yahooapis.com/forecastrss?p=FRXX0099&u=c}}.
\\
The JBI message response returned by the Yahoo Weather REST service 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}
h3. Consume mode
In this sample, we are going to expose a JBI service as REST service. The Service Unit configuration which will be used is :
todo
h1. Web Service Notifications
todo
h2. Intoduction
todo
h2. Create a WS-N topic
todo
h2. Subscribe to WS-N producer
todo
h2. Send a WS notification from a JBI message
When the petals-bc-soap component receives a JBI message on a topic-activated endpoint, it is transformed into a WS-notification message and published on the linked topic.
As an example of SOAP notification message, if the JBI message payload is :
{code:lang=xml}
<text>This is a sample of JBI message payload...</text>
{code}
and if it is published on the *'TopicSample'* topic, the SOAP body payload of the notification message will be :
{code:lang=xml}
<wsnt:Notify>
<wsnt:NotificationMessage>
<wsnt:SubscriptionReference>
<wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing">
http://127.0.0.1:8084/wsn-consumer/services/consumer
</wsa:Address>
</wsnt:SubscriptionReference>
<wsnt:Topic Dialect="xsd:anyURI">TopicSample</wsnt:Topic>
<wsnt:ProducerReference>
<wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing">
http://127.0.0.1:8084/wsn-producer/services/producer
</wsa:Address>
</wsnt:ProducerReference>
<wsnt:Message>
<text>This is a sample of JBI message payload...</text>
</wsnt:Message>
</wsnt:NotificationMessage>
</wsnt:Notify>
{code}
h1. Security
h2. Introduction
The SOAP binding component provides WS security features through the Axis2 rampart module ([http://ws.apache.org/rampart/|http://ws.apache.org/rampart/]).
This module is based on Apache WSS4J ([http://ws.apache.org/wss4j/|http://ws.apache.org/wss4j/]), an implementation of the OASIS WS-security specification ([http://www.oasis-open.org/committees/wss|http://www.oasis-open.org/committees/wss]).
This module is natively provided by the binding component since the 3.0 release.
h2. Securing JBI Services
h3. Configuration
todo
h3. Client side
todo
h2. Using WS-Policy
The [Apache Rampart|http://ws.apache.org/rampart/] module is used to apply policies when calling an external Web Service (ie in consumer mode). The current section explains how to configure the component to use this feature.
h3. Configuration
todo
h3. Usage
Once the Service Unit is deployed on the SOAP Binding Component, all the JBI messages sent to the new activated endpoint are transformed into SOAP messages and the Web Service client will use the Service Unit defined policy to call the Web Service. The Web Service client behaviour is exactly the same as a policy-enabled Axis2 based Web Service client.
An example of WS policy with PEtALS is provided in the PEtALS SOAP usecases at : [http://websvn.ow2.org/listing.php?repname=petals&path=/trunk/configurations/petals-soap/petals-soap-policy/|http://websvn.ow2.org/listing.php?repname=petals&path=/trunk/configurations/petals-soap/petals-soap-policy/].
h1. Samples
The SOAP binding component samples are available as packaged use cases. You can find them on {{trunk/configurations/petals-soap}} directory of the [Petals ESB forge|http://forge.ow2.org/plugins/scmsvn/index.php?group_id=213].
h1. Know problems
h2. "Transport out has not been set"
If the exception message "Transport out has not been set" occurs when invoking an external web-service, using the petals-bc-soap, it can be due to a wrong URL of the external web-service. Please check it and retry your test.
{column}
{column:width=350px}
{panel:title=Table of contents}{toc}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list}{panel}
{column}
{section}