Archive for the 'BPEL' Category



Error while using the HTTP Binding in BPEL

HTTP Binding can be used in BPEL to call the RESTful services. We might have come across one common error REPLACE_WITH_ACTUAL_URL while calling. Came across a metalink note that talks about this so thought of sharing the same.

Metalink Note ID: 1328955.1

Following are the few reasons that i found during my testing with the HTTP adapter to invoke REST based urls:

–  If the URL is not accessible from the server because of the firewall or HTTP proxy

– Using the XML complex types in the request structure.

Though, the metalink url says that XML complex types are not supported it’s working in 11.1.1.5 version ( i verified only in this version). The same working sample can be downloaded from here.

The example calls the Echo application which can be downloaded from  here (Antony Reynold’s blog).

Coherence in BPEL11g

After trying out with Result Caching feature in OSB, i tried to use the coherence in integration with BPEL to store and retrieve the frequently used data in cache. As OTN puts it, “Coherence provides replicated and distributed (partitioned) data management and caching services on top of a reliable, highly scalable peer-to-peer clustering protocol”. In this post, i want to explain the setup i tried with using SOA Suite 11.1.1.3. The weblogic 10.3.3 installer comes with coherence 3.5

Starting Servers

To use coherence in conjunction with BPEL, the servers have to be started in the following order:

    • Coherence server (cache-server.cmd)
    • Admin and SOA managed server.

Open cache-server.cmd file present in $FMW_HOME\coherence_3.5\bin and set the coherence_home variable as shown below. Replace $FMW_HOME with actual path as per your SOA suite installation.

       set coherence_home = $FMW_HOME\coherence_3.5

Open command window and issue the following commands to start the cache server.

    $<DOMAIN_HOME>\bin\setDomainEnv.cmd or set $JAVA_HOME

    set %PATH% = %JAVA_HOME%\bin;%PATH%

    cache-server.cmd

By default, multicasting is used for communication within coherence cluster. The multicast address and port will be visible in cache server start logs as shown below.

          image

In setDomainEnv.cmd file, modify EXTRA_JAVA_PROPERTIES variable to use above multicast address and port.

       image

In startWeblogic.cmd file, modify CLASSPATH variable to include coherence jar in server classpath.

SOA Composite Creation

We will create a simple BPEL process to demonstrate the use of coherence API to store and retrieve cache entries.

Create a sample SOA project in JDeveloper. Add coherence.jar to project libraries which can be found at location $FMW_HOME\coherence_3.5\lib. Create a BPEL process that accepts a string and returns another string.

        clip_image002

Create a java embedding activity with following code to verify whether the cache contains a value or not.

String cacheToken= ((oracle.xml.parser.v2.XMLElement) getVariableData ("varInput","payload","/client:process/client:input")).getFirstChild().getNodeValue();

//create new cache or to get the existing cache

NamedCache cache = CacheFactory.getCache("myCache");

//verify whether the key exists or not

setVariableData("valExists", cache.containsKey(cacheToken));

setVariableData("var1", cache.get(cacheToken));

Create a switch case in BPEL flow to call the actual service if the cache value does not exist for the token used. The following expression can be used in the switch case.

      bpws:getVariableData(‘valExists’)=string(true())

If the value is retrieved from cache, copy the value stored in ‘var1’ variable to output variable and do reply from BPEL process. Otherwise store the value we have got from the actual service in cache by using another java embedding activity with following code.

String cacheToken= ((oracle.xml.parser.v2.XMLElement) getVariableData("varInput","payload","/client:process/client:input")).getFirstChild().getNodeValue();

String cacheValue= ((oracle.xml.parser.v2.XMLElement) getVariableData("InvokeOutputVariable","parameters","/ns1:getResponse/val")).getFirstChild().getNodeValue();

NamedCache cache = CacheFactory.getCache("myCache");

cache.put(cacheToken,cacheValue);

setVariableData("var1",cache.get(cacheToken));

Execution of BPEL:

When result is not in Cache:

Run the BPEL by giving the value for ‘input’ element that does not exist in the cache currently. Here in this case, we are sending it as ‘NewUser’.

       image

         image

Observe that partner link has been called to get the result.

        image

When result is in Cache:

          image

Observe that partner link is not called and the result is fetched from the cache as expected.

          image

Strategies to Flush/Refresh the Cache:

  • Create a configuration parameter or BPEL property to specify whether cache has to be cleared or not. Modify the above switch condition to include this OR condition so that the existing cache will be reset by fetching the value again by calling the partner link.
  • Restarting the coherence server.

Namespace Issue

Today, for one of the tasks i need one sample WSDL so that i can create some mock service in SOAP UI. As usual wanted to leverage google search capabilities Smile for the same, instead of coming up with one on my own.

I have taken one of the WSDLs given in w3.org to my eclipse. I am surprised to see the errors given by eclipse for the WSDL. I made sure that the WSDL structure, namespace aliases etc. are given correctly.On careful examination of the inline XSD given in the WSDL, found the issue is with the namespace which is given as http://www.w3.org/1999/XMLSchema.

Modifying this namespace to http://www.w3.org/2001/XMLSchema resolved the error.

So the moral of the story is that some times blind copy does not give the intended time saving benefits as we expect.

Java Embedded Activity in BPEL

Today, it’s the first time that i worked with the Java Embedded Activity in BPEL 11g as i had a requirement of using coherence in the context of BPEL.

Came across one of the silly issues during this process so wanted to share the resolution of the same as i feel its the common mistake that can be done.

When i put the code in java embedded activity and rebuild the composite, i was getting the following error.

Error(23,34): Failed to compile bpel generated classes. failure to compile the generated BPEL classes for BPEL process "BPELProcess1" of composite "default/Project1!1.0"
The class path setting is incorrect.
Ensure that the class path is set correctly. If this happens on the server side, verify that the custom classes or jars which this BPEL process is depending on are deployed correctly. Also verify that the run time is using the same release/version.

The issue is coming as the necessary import statements are missing. To resolve this issue, add the import statements in the following way in .bpel file(these are the classes that i used) before the listing of partner links.

<bpelx:exec import="com.tangosol.net.CacheFactory"/>
<bpelx:exec import="com.tangosol.net.NamedCache"/>


Pages

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 379 other followers

Enter your email address to follow this blog and receive notifications of new posts by email.