Thursday 27 September 2012

Propagating Faults with an OSB Proxy

Summary

I recently have been using Oracle Service Bus (11g) to virtualise a series of web service endpoints. I was using the standard approach of:

  1. Importing resources from a WSDL
  2. Creating a Business Service based on that WSDL
  3. Creating a Proxy Service based on the Business Service
This all works well, except when it comes to the handling of faults. 

When I used the Business Service to test my web service through the OSB console, I would get the correct fault as a response:

<env:Fault xmlns:ns0="http://custom.com/Test/">
    <faultcode>ns0:DuplicatePrimaryKeyException</faultcode>
    <faultstring>
    <![CDATA[
        CAUSE. . . . . The Primary Key already exists
        RESOLUTION . . Please enter a valid Primary Key
        ]]>
    </faultstring>
    <faultactor/>
    <detail>
        <exception>&lt;exception/></exception>
    </detail>
</env:Fault>

However, making the same call via the Proxy Service, I would get the following fault:

<soapenv:Fault>
    <faultcode>soapenv:Server</faultcode>
    <faultstring>BEA-380001: Internal Server Error</faultstring>
    <detail>
        <con:fault xmlns:con="http://www.bea.com/wli/sb/context">
            <con:errorCode>BEA-380001</con:errorCode>
            <con:reason>Internal Server Error</con:reason>
            <con:location>
                <con:node>RouteTo_JDE_CustomItemMasterManager_BS</con:node>
                <con:path>response-pipeline</con:path>
            </con:location>
        </con:fault>
    </detail>
</soapenv:Fault>

I googled around for more information on OSB fault handling, and found the following excellent article:


The only problem was that it didn't exactly address what I was after, which was to simply propagate any faults from a Business Service to a Proxy Service.

Solution

I was able to use the information from the link above to solve my problem. The instructions below use the OSB console to modify the Proxy Service object, but you should be able to adapt them if using the Eclipse IDE:
  • Start a new change session by clicking Create in the Change Center
  • Locate your Proxy Service and select View Message Flow to start editing
  • Click on the RouteTo_<BusinessServiceName> and select Add Route Error Handler
  • Click on the new Error Handler and select Add Stage
  • Click on the new Stage and select Edit Name and Comments 
  • Enter a useful name (e.g. "Reply with Failure") and click Save
  • Click on the same Stage and select Edit Stage
  • Click the Add an Action link and select Flow Control -> Reply
  • Select the With Failure radio button and click Save All
  • Click Activate in the Change Center to save your changes.
The Proxy Service will now propagate the fault from the Business Service, instead of masking it and throwing a generic fault instead.

1 comment:

  1. I am unable to connect the bussiness url with routing step getting error BEA 380000 Internal server error, Can you please assist on me

    ReplyDelete