Sunday, July 5, 2015

Fault Handling Order of Precedence in BPEL 2.0



In BPEL 2.0, the order of precedence for catching faults thrown without associated data is as follows:

  • If there is a catch activity with a matching faultName value that does not specify a faultVariable attribute, the fault is sent to the identified catch activity.
  • Otherwise, if there is a catchAll activity, the fault is sent to the catchAll fault handler.
  • Otherwise, the fault is processed by the default fault handler.
In BPEL 2.0, the order of precedence for catching faults thrown with associated data is as follows:

  • If there is a catch activity with a matching faultName value that does not specify a faultVariable attribute, the fault is sent to the identified catch activity.
  • If the fault data is a WSDL message type in which the following exists:
  • The message contains a single part defined by an element.
  • There exists a catch activity with a matching faultName value that has a faultVariable whose associated faultElement QName matches the QName of the runtime element data of the single WSDL message part.
Then, the fault is sent to the identified catch activity with the faultVariable initialized to the value in the single part's element.

  • Otherwise, if there is a catch activity with a matching faultName value that does not specify a faultVariable attribute, the fault is sent to the identified catch activity. In this case, the fault value is not available from within the fault handler, but is available to the rethrow activity.
Business faults are application-specific faults that are generated when there is a problem with the information being processed (for example, when a social security number is not found in the database). A business fault occurs when an application executes a throw activity or when an invoke activity receives a fault as a response. The fault name of a business fault is specified by the BPEL process service component. The messageType, if applicable, is defined in the WSDL file. A business fault can be caught with a faultHandler using the faultName and a faultVariable

  • Otherwise, if there is a catch construct without a faultName attribute that has a faultVariable whose type matches the type of the runtime fault data, then the fault is sent to the identified catch activity.
  • Otherwise, if the fault data is a WSDL message type in which the message contains a single part defined by an element and there exists a catch activity without a faultName attribute that has a faultVariable whose associated faultElement QName matches the QName of the runtime element data of the single WSDL message part, the fault is sent to the identified catch activity with the faultVariable initialized to the value in the single part's element.
  • Otherwise, if there is a catchAll activity, the fault is sent to the catchAll fault handler.
  • Otherwise, the fault is handled by the default fault handler.

Fault Handling in a BPEL Process

Fault handling allows a BPEL process service component to handle error messages or other exceptions returned by outside web services, and to generate error messages in response to business or runtime faults.
 We will see how to use the fault management framework to catch faults and perform user-specified actions defined in a fault policy file

Fault Handler :

Fault handlers define how the BPEL process service component responds when web services return data other than what is normally expected (for example, returning an error message instead of a number). An example of a fault handler is where the web service normally returns a credit rating number, but instead returns a negative credit message.

<faultHandlers>
     <catch faultName="services:NegativeCredit" faultVariable="crError">
      <assign name="crin">
         <copy>
           <from expression="-1000">
           </from>
           <to variable="input" part="payload"
               query="/autoloan:loanApplication/autoloan:creditRating"/>
         </copy>
       </assign>
     </catch>
</faultHandlers>

The faultHandlers tag contains the fault handling code. Within the fault handler is a catch activity, which defines the fault name and variable, and the copy instruction that sets the creditRating variable to -1000.
When you select web services for the BPEL process service component, determine the possible faults that may be returned and set up a fault handler for each one.


Business and Runtime Fault Categories of BPEL Faults :


A BPEL fault has a fault name called a Qname (name qualified with a namespace) and a possible messageType. 

There are two categories of BPEL faults:

  • Business faults
  • Runtime faults
Business Faults :

Business faults are application-specific faults that are generated when there is a problem with the information being processed (for example, when a social security number is not found in the database).

 A business fault occurs when an application executes a throw activity or when an invoke activity receives a fault as a response. 

The fault name of a business fault is specified by the BPEL process service component. 

The messageType, if applicable, is defined in the WSDL file. 

A business fault can be caught with a faultHandler using the faultName and a faultVariable

<catch faultName="ns1:faultName" faultVariable="varName">

Runtime Faults :

Runtime faults are the result of problems within the running of the BPEL process service component or web service (for example, data cannot be copied properly because the variable name is incorrect). These faults are not user-defined, and are thrown by the system. They are generated for a variety of reasons, including the following:

  • The process tries to use a value incorrectly.
  • A logic error occurs (such as an endless loop).
  • A Simple Object Access Protocol (SOAP) fault occurs in a SOAP call.
  • An exception is thrown by the server.
Several runtime faults are automatically provided. These faults are included in the http://schemas.oracle.com/bpel/extension namespace. 

These faults are associated with the messageType RuntimeFaultMessage. The WSDL file shown in Example  defines the messageType:

<?xml version="1.0" encoding="UTF-8" ?> 
<definitions name="RuntimeFault"
  targetNamespace="http://schemas.oracle.com/bpel/extension"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns="http://schemas.xmlsoap.org/wsdl/">

  <message name="RuntimeFaultMessage">
   <part name="code" type="xsd:string" /> 
   <part name="summary" type="xsd:string" /> 
   <part name="detail" type="xsd:string" /> 
  </message>
</definitions>

If a faultVariable (of messageType RuntimeFaultMessage) is used when catching the fault, the fault code can be queried from the faultVariable, along with the fault summary and detail.


1 bindingFault

A bindingFault is thrown inside an activity if the preparation of the invocation fails. For example, the WSDL of the process fails to load. A bindingFault is not retryable. This type of fault usually must be fixed by human intervention.

2 remoteFault

A remoteFault is also thrown inside an activity. It is thrown because the invocation fails. For example, a SOAP fault is returned by the remote service.

3 replayFault

A replayFault replays the activity inside a scope. At any point inside a scope, this fault is migrated up to the scope. The server then re-executes the scope from the beginning.



BPEL Standard Faults :

This section identifies the standard faults for BPEL 1.1. Unless otherwise noted below, the Business Process Execution Language for Web Services Specification Version 1.1 defines the following standard faults in the namespace of http://schemas.xmlsoap.org/ws/2003/03/business-process/:

bindingFault (BPEL extension fault defined in http://schemas.oracle.com/bpel/extension)
conflictingReceive
conflictingRequest
correlationViolation
forcedTermination
invalidReply
joinFailure
mismatchedAssignmentFailure
remoteFault (BPEL extension fault defined in http://schemas.oracle.com/bpel/extension)
repeatedCompensation
selectionFailure
uninitializedVariable

Standard faults are defined as follows:

Typeless, meaning they do not have associated messageTypes

Not associated with any Web Services Description Language (WSDL) message

Caught without a fault variable:

<catch faultName="bpws:selectionFailure">


Interaction / Design Patterns in a BPEL Process

Common interaction patterns between a BPEL process service component and an external service includes:

  1. One-Way Messages
  2. Synchronous Interactions
  3. Asynchronous Interactions
  4. Asynchronous Interactions with a Timeout
  5. Asynchronous Interactions with a Notification Timer
  6. One Request, Multiple Responses
  7. One Request, One of Two Possible Responses
  8. One Request, a Mandatory Response, and an Optional Response
  9. Partial Processing
  10. Multiple Application Interactions

Thursday, April 23, 2015

How To Generate Deployment Plan in BPEL

Hi friends,

When we do code movement from one environment to other then we need some modification in code with respect to  url's,database connections etc.

We implement adapters ,web services using endpoint uri and jndi to develop application but these are different for each environment such as DEV,SIT,PROD etc.

To make this happen smoothly we create deployment plan for each environment and use it while deploying our composite.

Use the below steps in Jdeveloper to generate it.

1) Right click on the composite.xml file and select Generate Config Plan.


it will generate pop up with file name and click ok.

2) You can change all necessary fields accordingly.

e.g. Changing dev endpoint uri to test use below search and replace and do as per requirement.



 <!--Add search and replace rules for the import section of a composite
Example:
<searchReplace>
<search>JNDI_DEV</search>
<replace>JNDI_TEST</replace>
<searchReplace>
<searchReplace>
<search>URI_DEV</search>
<replace>URI_TEST</replace>
<searchReplace>-->

3) use this configuration plan file while deploying .sar in console.

Saturday, April 18, 2015

Dealing with images in DB Adapter in BPEL

Hi Friends,

I had a requirement to fetch image from database table as base64binary and sent it to the third party in the same format.

As we do regularly, i used select query(execute pure sql and select query option in DB adapter) and implemented but it didn't worked as expected. It was returning something like below image in BPEL Console.It was unable to parse in the proper format.




We raised SR with oracle and came to know that this is  because of the bug in DB Adapter while using select or execute pure sql option.

To achieve this we need to create a procedure /function from the same sql query and and use the option stored procedure or function execution in DB Adapter. It worked for this option.

Thanks.

Thursday, April 16, 2015

Difference Between : Routing action Vs Service Callout Vs Publish action in OSB

Routing action:

  •  When you need to call a synchronous service then use it.
  • In the message flow, regardless of whether routing takes place or not, the route node represents the transition from processing a request to processing a response.
  • Always Last Node in Message Processing
  • Only one Route node in a Proxy
  • A Route Node indicates that Request Processing will end here and Response Processing will begin
  • At the route node, the direction of the message flow is reversed.
  • Routing action can be created inside a Route Node only


Service Callout :

  • When you need to call a synchronous service and want to save req and resp variable for validation and enrichment.
  • Service Callout is used in real time request-response scenarios (for sync response).
  • If you have a use case where you need to call one or multiple real time request-response services (like sync web-services) then you may use Service Callout action in the message flow. 
  • Being a synchronous call, the thread gets blocked until a response is returned from target service.
  • Can have multiple Service Callout nodes in a Proxy service


Publish action :

  • Publish action is used for Request only scenarios where you don't expect a response back
  • The nature of Publish action (sync or async) will depend upon the target service you are invoking.
  • If you are invoking an external service through a business service then Publish action with Quality of Service(QoS) as "Best Effort" (default) will work like fire and forget and thread won't get blocked (async call). 
  • If you are invoking a local proxy service (proxy with transport protocol as "local") from another proxy using publish action then it would be a blocking call (synchronus call) and thread will get blocked untill the processing of local proxy finishes.


ref. - https://community.oracle.com/thread/1774545





Sunday, April 12, 2015

How to send a SOAP Header in BPEL

Hi Friends ,

Many times, we access a SOAP web service which has been secured by username and password.

We need to send these credentials in header part of the web service.

Lets do it....

1) Creating a XSD from the header payload.

Suppose my Header payload is like :

<?xml version="1.0" encoding="windows-1252" ?>
<Credential>
        <username>abc</username>
        <pwd>abc123</pwd>
</Credential>


Click on file and type xml and choose xml schema from xml as shown in below image.


2) Create a variable and select Type as xsd created from header payload as shown in below image.



3) Double click on Invoke activity which invokes the secured web service or you want to send a header in that service and click on header tab.



4) Check in Source  bpelx:inputHeaderVariable Created correctly.

<invoke name="Invoke_NotificationService"
            inputVariable="Invoke_NotificationService_commonNotificationDetails_InputVariable"
            partnerLink="Service1" portType="ns1:CommonNotification"
            operation="commonNotificationDetails" bpelx:invokeAsDetail="no"
            bpelx:inputHeaderVariable="Header"/>

Because some time it create wrongly as below

<invoke name="Invoke_NotificationService"
            inputVariable="Invoke_NotificationService_commonNotificationDetails_InputVariable"
            partnerLink="Service1" portType="ns1:CommonNotification"
            operation="commonNotificationDetails" bpelx:invokeAsDetail="no"
            bpelx:HeaderVariable="Header"/>

Thats it. Done.

Friday, April 3, 2015

Adding Multiple Sources in XSLT Transformation in BPEL

Hi Friends,

Many Times we need to point input from multiple source variables to one target in xslt mapper file.

There are two ways to deal with :

  • Add Multiple source variables while creating Transformation activity in bpel.
  • Create xsl file based on two xsd's and right click on source panel in xslt mapper in design view and select add source.
1) Adding multiple variables in Transformation Activity.
  • Drag and drop Transformation Activity
  • Go to Transformation tab and click + sign in Source and select required source variables
  • Select Target variables as per requirement.
See Below Snippet :



2) Adding Source to Already Created xsl mapper file.

Please follow below steps:



Thanks.

Tuesday, March 31, 2015

Error: there is no receive activity that starts the process

Problem :
              When using BPEL template  Define Service Later, gives below error while building it.

              Error(41): There is not an activity (receive/pick) to start the process
              Error(41): Initial activity is invalid. An initial activity must be of a receive or pick activity.
              Error: there is no receive activity that starts the process

Cause :
              This issue arises when you are using receive activity in BPEL .
               In this case you are using  BPEL template as Define Service Later and it generates
               receive activity code as below :

                           <receive name="Receive1" createInstance="no"
                             variable="Receive1_InputVariable"
                              partnerLink="Service1"
                               portType="ns1:getApplicationServiceSoap"
                            operation="getApplication"/>

           In above code you can see   createInstance="no" which is generated because you haven't checked Create Instance in receive activity as shown below.




Solution :

                To overcome this, you need to check Create Instance as shown in below or you can manually                                     change createInstance="no"  value to createInstance="yes" .


             

Saturday, March 28, 2015

XSLT Transformation file Design View not opening in Jdeveloper

Problem :
                 Design View XSLT transformation file(.xsl) not showing/opening.

Cause :
              Probably,It happens when you export Project from em console and import it in Jdeveloper.
               which removes oracle-xsl-mapper tag which contains mapSources and mapTargets.

Solution :
             Try to add manually  <?oracle-xsl-mapper>  tag after xml start tag and above stylshhet tag with                                   corresponding mapSources and mapTargets.

Sample Oracle-xsl-mapper :  which generates in xsl file when you create first time in jdev.

<?oracle-xsl-mapper
   <mapSources>
    <source type="WSDL">
      <schema location="../sourceWsdlName.wsdl"/>
      <rootElement name="sourceRootElement" namespace="sourceWsdlNamespace"/>
    </source>
  </mapSources>
  <mapTargets>
    <target type="WSDL">
      <schema location="targetWsdlLocation"/>
      <rootElement name="targetRootElement" namespace="targetNamespace/"/>
    </target>
  </mapTargets>
 ?>
               

Add the above code to your xsl file above stylesheet tag and do changes accordingly to your source and target as mentioned in Bold.

Please refer below screens shots  :




Unable to edit DB/File Adapter in JDeveloper

Problem :
                Unable to Edit DB/File Adapter in JDEV

Cause :
             It happens when you export Project from em console and import it in Jdeveloper .

Solution :

  • For File Adapter : 
                             Add  <?binding.jca jcafilename_file.jca?>  in corresponding wsdl below
                            <?xml version= '1.0' encoding= 'UTF-8' ?> tag generated when creating file adapter.

  • For DB Adapter :
                            Add  <?binding.jca jcafilename_db.jca?>  in corresponding wsdl below
                          <?xml version= '1.0' encoding= 'UTF-8' ?> tag  generated when creating DB adapter.



In case of DB Adapter Polling(Inbound), if you add <?binding.jca jcafilename_db.jca?>  tag and edit the db adapter then it is editable but with some error like below :



This error gives when you use Polling db records, in this case db adapter creates mapping and property files.

To overcome this issue you need to add below line in your properties.xml file above properties tag.

<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">


Understanding WSDL

Why WSDL...
  • When we create a service, we typically do it because we want other people to use it or reuse it.
  • In order for them to do that, they need to know ,
    • what information to send to the service,
    • what information the service is going to send back,
    • and where to find the service in the first place.
  • As communications protocols and message formats are standardized in the web community, it becomes increasingly possible and important to be able to describe the communications in some structured way.
  • WSDL addresses this need by defining an XML grammar for describing network services as collections of communication endpoints capable of exchanging messages.

Specifically WSDL is..
  • is an XML document
  • used to describe Web services
  • specifies the location of the service
  • specifies  the operations (or methods) the service exposes
The WSDL Document Structure..

Abstract Part : Describes
  • the messages it sends and receives
  • the operation associates a message exchange pattern with one or more messages
  • Types– a container for data type definitions using some type system (such as XSD).
  • Message– an abstract, typed definition of the data being communicated.
  • Operation– an abstract description of an action supported by the service.
  • Port Type–an abstract set of operations supported by one or more endpoints.
Concrete part : specifies
  • transport and wire format details for one or more interfaces
  • a port (an endpoint) associates a network address with a  binding
  • a service which groups together endpoints that implement a common interface
  • Binding– a concrete protocol and data format specification for a particular port type.
  • Port– a single endpoint defined as a combination of a binding and a network address.
  • Service– a collection of related endpoints