<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
   <channel>
      <title>SOA Tips</title>
      <link>http://blogs.oracle.com/imartin/</link>
      <description></description>
      <language>en</language>
      <copyright>Copyright 2009</copyright>
      <lastBuildDate>Tue, 03 Feb 2009 10:26:44 +0100</lastBuildDate>
      <generator>http://www.sixapart.com/movabletype/</generator>
      <docs>http://blogs.law.harvard.edu/tech/rss</docs> 

            <item>
         <title>End2End WS-Security with Oracle ESB (OESB)</title>
         <description><![CDATA[<p>Talking about SOA means talking about messages flowing all around the systems in the whole enterprise. Heterogeous systems exchange messages through the messaging infraestructure in place with local and/or external networks (when consuming external services, providing services to the internet, etcetera). In this situation P2P (point to point) security techniques like SSL are no more able to meet the security needs. So, how can those messages flow securely from consumer to provider and vice-versa?? That's what security techniques like XML encryption and XML digital signature have been created for.</p>

<p>One of the facts that the digital signature provides you with is data integrity. So, in case you have to use it you need to ensure the message is being transfered EXACTLY "as is" all way long. By default, this does not happen when using Oracle ESB as a mediator but this behaviour can now be changed using the 10.1.3.4.0 MLR#3 patchset.</p>

<p>In order to achieve the later, a new property has been defined for routing services: the "passthrough" property. Setting this property to true makes the ESB to send exactly the same message it has received thus making it happen. For more information take a look at  bug #6811827 in <a href="http://metalink.oracle.com">Metalink</a>.</p>]]></description>
         <link>http://blogs.oracle.com/imartin/2009/02/end2end_wssecurity_with_oracle.html</link>
         <guid>http://blogs.oracle.com/imartin/2009/02/end2end_wssecurity_with_oracle.html</guid>
                  <category domain="http://www.sixapart.com/ns/types#category">ESB</category>
                  <category domain="http://www.sixapart.com/ns/types#category">SOA</category>
                  <category domain="http://www.sixapart.com/ns/types#category">Security</category>
                  <category domain="http://www.sixapart.com/ns/types#category">Web Services</category>
        
        
         <pubDate>Tue, 03 Feb 2009 10:26:44 +0100</pubDate>
      </item>
            <item>
         <title>Customizing faults in WSM custom steps</title>
         <description><![CDATA[<p>Usually, WSM custom steps reflecting your own policy can lead to faults (as per the request not being compliant with the implemented policy). In those cases a custom SOAP fault will make sense in order to provide the invoker with details of the reason for the failure. The following code shows up how to generate such custom SOAP faults when creating WSM custom steps.</p>

<p><code><br />
package ....;</p>

<p>import com.cfluent.pipelineengine.container.MessageContext;<br />
import com.cfluent.policysteps.sdk.*;<br />
import javax.xml.soap.*</p>

<p>public class CustomStep1 extends AbstractStep {</p>

<p>&nbsp;&nbsp;private static final String CUSTOM_FAULT_NS = "http://my.custom.fault/ns";<br />
&nbsp;&nbsp;private static final String CUSTOM_DETAIL_NS = "http://my.custom.detail/ns";<br />
&nbsp;&nbsp;private static final String CUSTOM_DETAIL_PREFIX = "cd";</p>

<p>&nbsp;&nbsp;//setters and getters<br />
&nbsp;&nbsp;.....<br />
&nbsp;&nbsp;public IResult execute(IMessageContext msgContext) throws Fault {<br />
&nbsp;&nbsp;&nbsp;&nbsp;IResult result = new Result();<br />
&nbsp;&nbsp;&nbsp;&nbsp;MessageContext msgCtxt = (MessageContext) msgContext;</p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;//evaluate error condition (true for testing)<br />
&nbsp;&nbsp;&nbsp;&nbsp;boolean myFaultCondicionA = true;</p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;if (myFaultCondicionA) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw createCustomFaultA(msgCtxt, "detailValue1", "detailValue2");<br />
&nbsp;&nbsp;&nbsp;&nbsp;}</p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;return result;<br />
&nbsp;&nbsp;}<br />
  <br />
&nbsp;&nbsp;private Fault createCustomFaultA(MessageContext msgCtxt, String value1, String value2) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;return createFault(msgCtxt, "customCodeA", "error A description", new String[][] {{"CustomDetailA1", value1}, {"CustomDetailA2", value2}});<br />
&nbsp;&nbsp;}</p>

<p>&nbsp;&nbsp;private Fault createFault(MessageContext msgCtxt, String faultCodeQualifier, String faultString, String[][] values) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;try {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SOAPFactory factory = SOAPFactoryImpl.newInstance();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SOAPFault sf = msgCtxt.getRequest().getAxisMessage().getSOAPPart().getEnvelope().getBody().addFault();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Detail detail = sf.addDetail();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (int i = 0; i < values.length; i++)  {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DetailEntry de = detail.addDetailEntry(factory.createName(values[i][0] , CUSTOM_DETAIL_PREFIX, CUSTOM_DETAIL_NS));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;de.addTextNode(values[i][1]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return new Fault(CUSTOM_FAULT_NS, faultCodeQualifier, faultString, null, detail);<br />
&nbsp;&nbsp;&nbsp;&nbsp;} catch (SOAPException soape) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return new Fault(soape);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;}<br />
}<br />
</code><br />
<BR /><br />
<BR /><br />
<BR /><br />
The result obtained because of the execution of the former code looks like this:</p>

<p><code><br />
&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;<br />
&nbsp;&nbsp;&lt;SOAP-ENV:Body&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;SOAP-ENV:Fault&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;faultcode xmlns:p="http://my.custom.fault/ns"&gt;p:Client.customCodeA&lt;/faultcode&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;faultstring&gt;error A description&lt;/faultstring&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;detail&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;cd:CustomDetailA1 xmlns:cd="http://my.custom.detail/ns"&gt;detailValue1&lt;/cd:CustomDetailA1&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;cd:CustomDetailA2 xmlns:cd="http://my.custom.detail/ns"&gt;detailValue2&lt;/cd:CustomDetailA2&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/detail&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/SOAP-ENV:Fault&gt;<br />
&nbsp;&nbsp;&lt;/SOAP-ENV:Body&gt;<br />
&lt;/SOAP-ENV:Envelope&gt;<br />
</code></p>]]></description>
         <link>http://blogs.oracle.com/imartin/2008/11/customizing_faults_in_wsm_cust.html</link>
         <guid>http://blogs.oracle.com/imartin/2008/11/customizing_faults_in_wsm_cust.html</guid>
                  <category domain="http://www.sixapart.com/ns/types#category">SOA</category>
                  <category domain="http://www.sixapart.com/ns/types#category">Web Services</category>
        
        
         <pubDate>Mon, 24 Nov 2008 13:50:57 +0100</pubDate>
      </item>
            <item>
         <title>WS asynchrony models (BPEL Vs JAX-WS)</title>
         <description><![CDATA[<ul>
  <li><a href="#introduction">Introduction</a>  </li>
  <li><a href="#implementations">Asynchronous model implementations</a></li>
  <ul>
    <li><a href="#bpelimpl">BPEL asynchronous model</a></li>
    <li><a href="#jaxwsimpl">JAX-WS asynchronous model</a></li>
  </ul>
  <li><a href="#adaptingwsdl">Adapting a JAX-WS WSDL for BPEL</a></li>
  <ul>
    <li><a href="#adaptingports">Adapting the portType definition</a></li>
    <li><a href="#adaptingbindings">Adapting the binding definition</a></li>
    <li><a href="#adaptingservice">Adapting the service definition</a></li>
  </ul>
  <li><a href="#addressing">WS-Addressing</a></li>
  <ul>
    <li><a href="#addressingrequest">Sending http://www.w3.org/2005/08/addressing WS-Addresing headers</a></li>
    <li><a href="#addressingresponse">Receiving http://www.w3.org/2005/08/addressing WS-Addresing header in Oracle BPEL PM</a></li>
  </ul>
</ul>
<h2 id="introduction">Introduction</h2>

<p>In the Web Services world an asynchonous call means sending a message to a remote service and then wait for it to send the response back to the caller </p>

<p>(a.k.a. callback). Talking in HTTP terms this means two different HTTP connections: one from the client to the service provider and the other from the </p>

<p>provider to the client. As the same client can call several times to an asynchonous service the incoming callbacks must be correlated with the invocations. <br />
WS-Addressing <a href="#REF_WSA">[WSA]</a> is the standard used for this correlation. This standard defines a set of SOAP headers needed to achieve </p>

<p>correlation. The most important ones are:</p>

<table width="90%"  border="0">
  <tr>
    <td width="15">&nbsp;</td>
    <td colspan="2">- 	Invoke</td>
  </tr>
  <tr>
    <td width="15">&nbsp;</td>
    <td width="15">&nbsp;</td>
    <td><li>MessageID: Identifies the conversation</li></td>
  </tr>
  <tr>
    <td width="15">&nbsp;</td>
    <td width="15">&nbsp;</td>
    <td><li>ReplyTo: Indicates the URL where the client waits for the callback to be sent</li></td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr>
    <td width="15">&nbsp;</td>
    <td colspan="2">- Callback</td>
  </tr>
  <tr>
    <td width="15">&nbsp;</td>
    <td width="15">&nbsp;</td>
    <td><li>RelatesTo: Identifies the conversation so the client can correlate with the request</li></td>
  </tr>
</table>
<BR/>
<table width="90%"  border="0">
  <tr>
    <td width="15">&nbsp;</td>
    <td ><img src="http://blogs.oracle.com/imartin/asynchrony/img/asynchony_80.jpg" border="1" width="600"></td>
  </tr>
  <tr>
    <td width="15">&nbsp;</td>
    <td align="center">Fig. 1 - Asynchonous invocation message interchange</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>

<h2 id="implementations">Asynchronous model implementations</h2>

<p>Each SOAP stack provides it's own implementation of the asynchonous model and problems may occurr when the client and the provider use different SOAP stack. </p>

<p>This document describes the specific case of invoking a JAX-WS asynchronous service from Oracle BPEL 10.1.3.1. Let's take a look to both models to see the </p>

<p>difference.</p>

<h3 class="parahead2" name="bpelimpl">BPEL asynchronous model</h3>

<p>In BPEL the asynchonous model is implemented via two Web Services. An asynchronous BPEL service exposes two services in it's WSDL as shown in the following </p>

<p>pictures:</p>

<table width="90%"  border="0">
  <tr>
    <td align="center"><img src="http://blogs.oracle.com/imartin/asynchrony/img/bpel_asynch_model_request_80.JPG" border="1" width="600"></td>
  <tr>
    <td  align="center">Fig. 2 - BPEL process asynchronous WSDL (request highlighted)</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td align="center"><img src="http://blogs.oracle.com/imartin/asynchrony/img/bpel_asynch_model_response_80.JPG" border="1" width="600"></td>
  </tr>
  <tr>
    <td align="center">Fig. 3 - BPEL process asynchronous WSDL (response highlighted)</td>
  </tr>
</table>

<p>The former is to be implemented by the service itself to receive the invocation. The later is to be implemented by the client in order to receive the </p>

<p>callback.</p>

<h3 name="jaxwsimpl">JAX-WS asynchronous model</h3>

<p>As you can see in the picture below a JAX-WS asynchonous service does only expose one service. The asynchrony affects only to the implementation and not to </p>

<p>the service description itself. The runtime behaviour is the same as in the BPEL case. The only difference is in the way they service is described.</p>

<table width="90%"  border="0">
  <tr>
    <td width="15">&nbsp;</td>
    <td align="center"><img src="http://blogs.oracle.com/imartin/asynchrony/img/jaxws_asynch_model_80.JPG" border="1" width="600"></td>
  </tr>
  <tr>
    <td width="15">&nbsp;</td>
    <td align="center">Fig. 4 - JAX-WS asynchronous WSDL</td>
  </tr>
</table>

<h2 name="adaptingwsdl">Adapting a JAX-WS WSDL for BPEL</h2>

<p>The target is to create a WSDL equivalent to the JAX-WS one but adapted to the BPEL style so the runtime behaviours get equal.</p>

<h3 name="adaptingports">Adapting the portType definition</h3>

<p>As we saw previously as there's only one portType in the JAX-WS WSDL it has to be broken down into two. The output of the original portType has to be removed </p>

<p>from it. The new portType has the original one's output as input as it's going to be used for callback.</p>

<table width="90%"  border="0">
  <tr>
    <td width="15">&nbsp;</td>
    <td align="center"><img src="http://blogs.oracle.com/imartin/asynchrony/img/porttype_jaxws_style.JPG" border="1" width="600"></td>
  </tr>
  <tr>
    <td width="15">&nbsp;</td>
    <td align="center">Fig. 5 - JAX-WS sample portType tag</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td width="15">&nbsp;</td>
    <td align="center"><img src="http://blogs.oracle.com/imartin/asynchrony/img/porttype_jaxws_modified_style.JPG" border="1" width="600"></td>
  </tr>
  <tr>
    <td width="15">&nbsp;</td>
    <td align="center">Fig. 6 - JAX-WS sample portType tag (Modified)</td>
  </tr>
</table>

<p></p>

<p></p>

<h3 name="adaptingbindings">Adapting the binding definition</h3>

<p>We have to act the same way with the binding. It has to be broken down into two bindings following the same rules used for the portType. First, the output </p>

<p>must be removed from the original binding. Then a binding has to be created for the callback portType. Again, the ouput from the original one becomes the </p>

<p>input of this one.</p>

<table width="90%"  border="0">
  <tr>
    <td width="15">&nbsp;</td>
    <td ><img src="http://blogs.oracle.com/imartin/asynchrony/img/binding_jaxws_style.JPG" border="1" width="600"></td>
  <tr>
    <td width="15">&nbsp;</td>
    <td >Fig. 7 - JAX-WS sample binding tag</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td width="15">&nbsp;</td>
    <td ><img src="http://blogs.oracle.com/imartin/asynchrony/img/binding_jaxws_modified_style.JPG" border="1" width="600"></td>
  <tr>
    <td width="15">&nbsp;</td>
    <td >Fig. 8 - JAX-WS sample binding tag (Modified)</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>

<h3 name="adaptingservice">Adapting the service definition</h3>

<p>Finally, a new service has to created. It has to be associated to the recently created portType and binding. The location needs not to have a existing URL as </p>

<p>the WS-Addresing headers will tell the remote service where to send the callback message.</p>

<table width="90%"  border="0">
  <tr>
    <td width="15">&nbsp;</td>
    <td ><img src="http://blogs.oracle.com/imartin/asynchrony/img/service_jaxws_style.JPG" border="1" width="600"></td>
  <tr>
    <td width="15">&nbsp;</td>
    <td >Fig. 9 - JAX-WS sample service tag</td>
  </tr>
  <tr>
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr>
    <td width="15">&nbsp;</td>
    <td ><img src="http://blogs.oracle.com/imartin/asynchrony/img/service_jaxws_modified_style.JPG" border="1" width="600"></td>
  <tr>
    <td width="15">&nbsp;</td>
    <td >Fig. 10 - JAX-WS sample service tag (Modified)</td>
    </tr>
</table>

<h2 name="addressing">WS-Addressing</h2>

<p>There are several addresing headers and all of them are valid. Oracle BPEL PM 10.1.3.1 uses the ones in the <span </p>

<p><span class="CODE">http://schemas.xmlsoap.org/ws/2003/03/addressing</span> namespace. In order to use different addressing headers (E.g. the ones in the </p>

<p>http://www.w3.org/2005/08/addressing namespace) the following has to be done:</p>

<h3 name="addressingrequest">Sending http://www.w3.org/2005/08/addressing WS-Addresing headers</h3>

<p>Some messages have to be defined to send out the theese addressing headers. One for each header we want to be included.</p>

<table width="90%"  border="0">
  <tr>
    <td width="15">&nbsp;</td>
    <td ><img src="http://blogs.oracle.com/imartin/asynchrony/img/wsa_messages.JPG" border="1 width="600""></td>
  <tr>
    <td width="15">&nbsp;</td>
    <td >Fig. 11 - http://www.w3.org/2005/08/addressing messages</td>
  </tr>
</table>

<p>The bindings have also to be modified to indicate the headers we want to be sent and received. Each header declaration points to the correspondent message </p>

<p>from the described above.</p>

<table width="90%"  border="0">
  <tr>
    <td width="15">&nbsp;</td>
    <td ><img src="http://blogs.oracle.com/imartin/asynchrony/img/wsa_bindings.JPG" border="1" width="600"></td>
  <tr>
    <td width="15">&nbsp;</td>
    <td >Fig. 12 - Bindings including headers</td>
  </tr>
</table>

<h3 name="addressingresponse">Receiving http://www.w3.org/2005/08/addressing WS-Addresing header in Oracle BPEL PM</h3>

<p>As, by default, Oracle BPEL PM searchs only for the http://schemas.xmlsoap.org/ws/2003/03/addressing headers for correlation a specific handler has to be </p>

<p>deployed. The code shown here is a header handler. It looks for the addressing header and in case it finds it sets the conversation ID (the attribute used </p>

<p>for correlation) with the header's value.</p>

<p>In order to develop a BPEL header handler the com.collaxa.cube.engine.handlers.IMessageHandler interface has to be implemented. To compile it the Jar files </p>

<p>located at the Oracle BPEL PM library folder have to be in the classpath.</p>

<table width="90%"  border="0">
 <tr>
  <td width="15">&nbsp;</td>
  <td ><img src="http://blogs.oracle.com/imartin/asynchrony/img/header_handler.JPG" border="1" width="600"></td>
  <tr>
    <td width="15">&nbsp;</td>
    <td >Fig. 13 - http://www.w3.org/2005/08/addressing header handler source code</td>
  </tr>
</table>			

<p>To deploy it to the Oracle BPEL PM engine just copy the class (with the required folder structure) to the $BPEL_HOME/system/classes folder. Then, edit the </p>

<p>message-handlers.xml file located at $BPEL_HOME/domains/<domain>/config folder. Include a new message-handler tag for the handler and include it in the </p>

<p>inbound-flow tag. After restarting BPEL the handler will start working.</p>

<table width="90%"  border="0">
  <tr>
    <td width="15">&nbsp;</td>
    <td ><img src="http://blogs.oracle.com/imartin/asynchrony/img/message_handler_config.JPG" border="1" width="600"></td>
  <tr>
    <td width="15">&nbsp;</td>
    <td >Fig. 14 - Message handler configuration</td>
  </tr>
</table>	

<h2>Additional Resources</h2> 
<p> <a name="REF_WSA"><a target="_blank" href="http://www.w3.org/TR/ws-addr-core/"><b>[WSA]</b> W3C WS-Addressing Core</a><br>
      <p> <a name="REF_JAXWS"><a target="_blank" href="http://jax-ws.dev.java.net"><b>[JAX-WS]</b> JAX-WS at Java.net</a><br>]]></description>
         <link>http://blogs.oracle.com/imartin/2008/09/ws_asynchrony_models_bpel_vs_j_1.html</link>
         <guid>http://blogs.oracle.com/imartin/2008/09/ws_asynchrony_models_bpel_vs_j_1.html</guid>
                  <category domain="http://www.sixapart.com/ns/types#category">BPEL</category>
                  <category domain="http://www.sixapart.com/ns/types#category">SOA</category>
                  <category domain="http://www.sixapart.com/ns/types#category">Web Services</category>
        
        
         <pubDate>Tue, 30 Sep 2008 16:57:06 +0100</pubDate>
      </item>
      
   </channel>
</rss>
