Sunday, June 23, 2013

How to Retrieve Payload From SOA Dehydration Store Using Java

Oracle has provided SOA facade and management api to retrieve the composite/instance details from the soa-infra database. List of composite instances can be retrieved based on any filter condition like between 2 dates, by instance id, by state etc. The API documentation is available at -

http://docs.oracle.com/cd/E21764_01/apirefs.1111/e10659/oracle/soa/management/facade/package-summary.html

And the detailed documentation is here -

http://docs.oracle.com/cd/E28280_01/admin.1111/e10226/soaadmin_apimanage.htm

I am listing here a code excerpt to retrieve the list of bpel instances between a give date. The actual code was to retrieve the payload that instantiated the bpel for each bpel instance in list.

First set the filter condition -

locator = LocatorFactory.createLocator(props);
CompositeInstanceFilter filter = new CompositeInstanceFilter();
filter.setMinCreationDate(minCreationDate);
filter.setMaxCreationDate(maxCreationDate);

then get the list of instances -

 List<CompositeInstance> compositeInstance =

                locator.getCompositeInstances(filter);



List<ComponentInstance> childComponentInstances;


get child component instances list by iterating through the list.

for (CompositeInstance compositeInstance1 : compositeInstance) {
                childComponentInstances =                        compositeInstance1.getChildComponentInstances(cInstanceFilter);
                                
System.out.println("Child list size -> " +                                   childComponentInstances.size()+" | name -"+compositeInstance1.getCompositeDN().getCompositeName());


iterate through childComponentInstances list to retrieve the details. AuditTrail can also be retrieved for a particular instance here in this loop.

for (ComponentInstance componentInstance1 :
                         childComponentInstances) {
System.out.println("++++++++++++++++ " +
                               componentInstance1.getComponentName() +
                                           "| Version - " + componentInstance1.getCompositeDN().getRevision() +
" | Instance ID - " +                                        componentInstance1.getCompositeInstanceId() +
" | " +                                        componentInstance1.getCreationDate());
}

}


For complete code please mail me.

Friday, June 14, 2013

Error While Throwing SOAPFaultException From Java Embedding to BPEL - "This class does not support SAAJ 1.1"

This post is valid for SOA 11.1.1.6.

Before looking at how to resolve "This class does not support SAAJ 1.1" error, here are some rules to consider while using java embedding activity in bpel.


  • BPEL 2.0 syntax to import a java class is -

<import location="com.oracle.bpel.client.BPELFault" importType="http://schemas.oracle.com/bpel/extension/java"/>
  • All custom jars must be added to the classpath and lib (SCA-INF/lib) folder of the soa project as shown in the image below.





  • Java embedding can only invoke static methods from the custom jars else you will see an error "failed to compile excelet" while deploying soa project. Make sure that the function that you are invoking from custom jar is static function.


  • BPEL understands only BPELFaults. Java exceptions must be caught within a java embedding try-catch block and inside catch block BPELFault needs to be raised like in the code excerpt below.

try {            
    String response = WebserviceHTTPClient.invoke(webserviceURL, operationName, 
                                            bodyContent);     
    addAuditTrailEntry(">>>>>>>> Response - "+response); 
} catch (Exception e){                          
    addAuditTrailEntry(">>>>>>>> Exception - "+ e.getMessage());      
    QName qName = new QName("http://schemas.oracle.com/bpel/extension", "remoteFault");      
     
    // create a new BPELFault exception      
    BPELFault bpelFault = new BPELFault(qName);      
     
    // set the details of the fault      
    bpelFault.setPart("code", "2001");      
    bpelFault.setPart("summary", "some error");      
    bpelFault.setPart("detail", e.getMessage());      
     
    // throw the fault      
    throw bpelFault;      
}


Now about how to resolve SAAJ version error. The solution is provided here but I am listing as a note for me as the scenario I encountered for this issue is slightly different -


Scenario - A custom jar method is invoked in java embedding which is throwing SOAPFaultException. Java embedding  catches the exception and try to build BPELFault. But the message retrieved from the exception caught shows - "This class does not support SAAJ 1.1" instead of the actual soap fault error message.

Resolution - Weblogic has a default SAAJ implementation in package weblogic.webservice.core.soap, that seems be causing this issue. Hence we need to override the properties to use a better implementation weblogic.xml.saaj  package. To override add this to your startWeblogic script and restart the server.

-Djavax.xml.soap.MessageFactory=weblogic.xml.saaj.MessageFactoryImpl

Earlier I have also encountered "There was no content-type header" message in java embedding catch block.  This was because the MimeHeader passed to build SOAPFault was null.

Demystifying OIC, OCI and Oracle SOA CS

What is OIC (Oracle integration cloud), OCI (Oracle cloud infrastructure), and SOA cloud service and how they are different? - This has bee...