Monday, December 9, 2013

Setting A Timeout For A Web Service in SOA Suite 11g

Objective 

This post explains how to set a TIMEOUT for a  Web Service invocation when using SOA 11g .

This applies to both BPEL and Mediator and can be used when only the Web Service invocation is made through HTTP. 

Solution

1. For a process that invokes a Web Service, we want to set a timeout of maximum 10 seconds that the SOA application will wait for the answer. If no response is received within the specified timeout, then we want to catch the timeout error and perform a series of other activities.

The sample below is for a BPEL in a SOA Composite - it will work the same way with Mediator as the timeout is set in composite.xml file and not in some specific BPEL file .

2. Let's say the SOA composite looks like this:



3. Click on  "Service1" and note that the property inspector will open in the lower right side of your JDeveloper window. Here set the property :

oracle.webservices.httpReadTimeout = 10000

If the Web Service is on the same domain as the SOA Composite , we need have to set 

oracle.webservices.local.optimization = false

By default the local optimization is TRUE and when a SOA composite invokes another SOA composite within the same Weblogic (WLS) server or cluster of WLS servers bypasses the whole SOAP stack, and makes a direct java call to optimize the invocation.

You may set these properties directly in composite.xml as follows :




4. In the BPEL process we can add a Catch branch for a RemoteFault if wewant to catch this error . 

5. Now deploy the composite and run it from EM page . The Web Service we are calling takes 30 seconds to complete , but we set the timeout to 10 seconds - note that the Remote Fault occurs after 10 seconds.



6. Other way is the BPEL only, it's possible to use "Timeout" option for Invoke or Receive activities.Note when using this parameter it will return a "bpelx:timeout" Fault, and not a Remote Fault


Wednesday, January 23, 2013

For Each Action In OSB


I was replying to OTN  forum post regarding OSB For each action at :


So thought of writing it down to make it more clear.....

  1. I have made xml based proxy service.



2. I assumed the payload would be 

<request>
<CompanyCollection>
<company>
<name>name1</name>
</company>
<company>
<name>name2</name>
</company>
</CompanyCollection>
<CompanyCollection>
<company>
<name>name3</name>
</company>
<company>
<name>name4</name>
</company>
</CompanyCollection>
</request>

3. Assigned $body to companycollreq ( user defined variable) using Assign action
    
4. To keep a count of companycollection elemennt in the  request payload
   Assign count($companycollreq/request/CompanyCollection) to  companyCount
   


5. Now use a for each action to iterate over companycollection
    For each expression would like as:
   For Each variable companycoll   in ./request/CompanyCollection of variable  companycollreq 
   Indexed by variable currIndex with total count in variable  companycount


6.  Under Do 
      I am logging the companycollection element based upon the currindex count in for loop.
      This is important as we need to pass payload under iteration in for loop. 

     Assign $companycollreq/request/CompanyCollection[xs:int($currIndex)] in log action with annotation 
     of companycoll

Now Testing is done with above payload.


In Console logs obtained:



This is how for each action works.
Log action runs twice as companycollection count was two in payload passed.
In place of log action we can use service callout/Publish/Java callout .
The payload passed must contain currIndex as xquery predicates expression while passing value to other services being called from for loop.