My take on SOA,Oracle BPEL, ESB, OSB, BPM,iPaas, cloud computing, AWS ,MEAN stack.
Friday, May 27, 2011
How to add/modify BPEL /B2B/Mediator (component) properties – Where it gets stored?
Wednesday, June 2, 2010
SOASuite 11g- Implement User-Defined XPath Extension Functions
I had previously written a blog on creating XPATH function in 10g. This write up is on how to achieve the same in 11g.
In 11g the major difference is that XPATH functions has been extended to some more components.
· BPEL
· Mediator
· Human workflow
· XSLT Mapper
The implementation is different only for XSLT mapping. For all other components implementation is same. Functions can be shared across all components and is defined by the xpath-functions-config xml file.
For each component we will define functions in a component specific config file
BPEL - ext-bpel-xpath-functions-config.xml
Mediator - ext-mediator-xpath-functions-config.xml
XSLT Mapper - ext-mapper-xpath-functions-config.xml
Common to all - ext-soa-xpath-functions-config.xml
I will explain the steps involved to create user-defined Xpath function for both BPEL and XSL mapper.
BPEL
For creating user-defined XPATH function, we need to define a java component and a xml component .The Xml component will take care of the configuration where as java component will be the implementation of the function.
We will start with xml component. We will define the function interface in a xml format.
1. Create an xml file - ext-bpel-xpath-functions-config.xml
Add this xml snippet
<soa-xpath-functions version="11.1.1"
xmlns="http://xmlns.oracle.com/soa/config/xpath"
xmlns:geo="http://www.geo-functions.com/HelloWorld">
<function name="geo:helloWorld">
<className>com.geo.xpath.HelloWorldTest</className>
<return type="string"/>
<params>
<param name="value" type="string"/>
</params>
<desc/>
<detail>
<![CDATA[This function returns a HelloWorld message.]]>
</detail>
</function>
</soa-xpath-functions>
here function signature is helloWorld() ,The namespace of the function is xmlns:geo=http://www.geo-functions.com/HelloWorld
2. Create a simple java class to implement the XPATH BPEL function.
The java class should implement oracle.fabric.common.xml.xpath.IXPathFunction interface. You can find this class and related xpath functions in fabric-runtime.jar
Code Snippet HelloWorldTest.java
package com.geo.xpath;
import oracle.fabric.common.xml.xpath.IXPathFunction;
import oracle.fabric.common.xml.xpath.IXPathContext;
import oracle.fabric.common.xml.xpath.XPathFunctionException;
import java.util.List;
public class HelloWorldTest implements IXPathFunction {
public Object call(IXPathContext context, List args) throws XPathFunctionException {
return "Hello world :: "+args.get(0);
}
}
You need to have fabric-runtime.jar in your classpath for compiling this java class.
>javac -classpath lib\ fabric-runtime.jar -d classes com\geo\xpath\HelloWorldTest.java
Here lib points to the location of these jars. –d classes points to the output folder where I will get my class file.
3. Create a jar with the generated class file.
>jar -cvf helloWorld.jar com/geo/xpath/HelloWorldTest.class
The jar will not be complete without the configuration file. Now add the ext-bpel-xpath-functions-config.xml file to the
Development of custom XPATH function is done. Now we will use it.
Usage
In the BPEL process use an assign operation to invoke the function
Code Snippet of .bpel file
<assign name="Assign_1">
<copy>
<from expression="geo:helloWorld(string(bpws:getVariableData('inputVariable','payload','/client:process/client:input')))"/>
<to variable="Invoke_1_execute_InputVariable" part="request"
query="/ns3:singleString/ns3:input"/>
</copy>
</assign>
When you compile the bpel process you will get a compilation error because the namespace-prefix and namespace-uri are not declared in the bpel process. Add the namespace- prefix and namespace-uri from your new function defined in ext-bpel-xpath-functions-config.xml to the process tag of .bpel file
Code Snippet of .bpel file
<process name="XpathBpel" targetNamespace="http://xmlns.oracle.com/XpathBpel"
……….
……. xmlns:geo="http://www.geo-functions.com/HelloWorld"
>
Compile and deploy your bpel process. The output will be the return string of the call method defined in the function.
Runtime usage:
1. Copy the HelloWorld function jar to MIDDLEWARE_Home/user_projects/domains/soa_domain/lib or a subdirectory of lib.
2. Restart the Oracle WebLogic Server.
XSLT Mapper
As we did for BPEL, we need to define a java component and a xml component .The Xml component will take care of the configuration where as java component will be the implementation of the function.
We will start with xml component. We will define the function interface in an xml format.
1. Create an xml file - ext-mapper-xpath-functions-config.xml
Add this xml snippet
<soa-xpath-functions version="11.1.1"
xmlns="http://xmlns.oracle.com/soa/config/xpath"
xmlns:geo="http://www.oracle.com/XSL/Transform/java/com.geo.xpath.HelloWorldXSLTest">
<function name="geo:helloWorldXSL">
<className>com.geo.xpath.HelloWorldXSLTest</className>
<return type="string"/>
<params>
<param name="value" type="string"/>
</params>
<desc/>
<detail>
<![CDATA[This function returns a HelloWorld message.]]>
</detail>
</function>
</soa-xpath-functions>
Here function signature is helloWorldXSL() ,The namespace of the function is xmlns:geo= http://www.oracle.com/XSL/Transform/java/com.geo.xpath.HelloWorldXSLTest". The difference with BPEL XPATH function is the namespace. Here the namespace should be in a specific format. http://www.oracle.com/XSL/Transform/java/ + package name +Class name
2. Create a simple java class to implement the XPATH BPEL function. A point to note is that for each function you need to write a corresponding public static method. The function name and method name must match.
Code Snippet HelloWorldXSLTest.java
package com.geo.xpath;
public class HelloWorldXSLTest {
public static String helloWorldXSL(String input){
return "Hello worldXSL :: "+input;
}
}
Compile this java class.
>javac -d classes com\geo\xpath\HelloWorldXSLTest.java
3. Create a jar with the generated class file.
>jar -cvf helloWorldXSL.jar com/geo/xpath/HelloWorldXSLTest.class
The jar will not be complete without the configuration file. Now add the ext-mapper-xpath-functions-config.xml file to the
Development of custom XSL Mapper XPATH function is done. Now we will use it.
Usage
JDeveloper will support user defined XSL functions .To use it from the wizard
· In Oracle JDeveloper, go to Tools > Preferences > SOA.
· Click the Add button and select your JAR file.
· Restart Oracle JDeveloper for the changes to take effect.
The function will be listed in the user-defined functions under Component Palette. You can directly drag and drop into your XSL.
Code Snippet of .xsl file
<xsl:stylesheet version="1.0"
xmlns:geo="http://www.oracle.com/XSL/Transform/java/com.geo.xpath.HelloWorldXSLTest"
…………
…………..
>
<xsl:template match="/">
<client:processResponse>
<client:result>
<xsl:value-of select="geo:helloWorldXSL(/client:process/client:input)"/>
</client:result>
</client:processResponse>
</xsl:template>
</xsl:stylesheet>
Compile and deploy your bpel/mediator process having your XSL mapping file. The output will be the return string of the method defined in the function.
Runtime usage:
1. Copy the HelloWorldXSL function jar to MIDDLEWARE_Home/user_projects/domains/soa_domain/lib or a subdirectory of lib.
2. Restart the Oracle WebLogic Server.
That’s it J
Wednesday, May 26, 2010
Dehydration/internal schemas in SOA 10g and SOA11g
One of the queries that I got recently was about the differences in the dehydration/internal schemas used from SOA 10g and SOA11g. So today’s blog is on what changed from 10g to 11g as far as dehydration/internal schemas are concerned. In SOA 10g BPEL engine used orabpel schemas extensively for storing the process as well as the instance audit details. ESB engine used oraesb schema for all its internal communications by using different topics (ERROR, CONTROL, MONITOR etc) as well as important server parameters. In the case of SOA 11g since the entire architecture has been revamped, the internal schemas were refactored so as to fit in the scheme of things.
In SOA11g BPEL and Mediator engine requires
During startup of the soa-infra application, BPEL and Mediator engines are initialized and after that it will load all the composites from the
Friday, May 21, 2010
Event delivery Network – publishing events using SQL API
Business Events always had been an interesting option when it comes to initial design of an interface. For all real time integrations, we will always prefer a business event in case end system supports it. In scenarios where business events are not supported, applications are developed to sense pre-defined conditions or continuously poll for new events. But these do not offer the flexibility and scalability required to handle new and more complex changes that will come in the future. In other scenarios, the business event feature may be there but the business event may not contain the entire payload which needs to be fetched using the ids provided as part of the business event data. Business Events is one of the new features in SOA Suite 11g, named as the Event Delivery Network (EDN). Event-driven architecture can always complement service-oriented architecture (SOA) because services can be activated by triggers fired on incoming events.
Refer the blog by Clemens on how to publish/subscribe to an event using Java APIs
http://blogs.oracle.com/soabpm/2009/07/event_delivery_network_chapter.html
I will throw some light on the steps involved as well as the internal APIs provided by EDN that you can use to publish events.
Publisher and Subscriber needs to be aware of the data format that they need to communicate in. So the first step will be to define the Payload of the business event. For this define an XSD schema which will become your payload.
On subscriber side we need to define Business Event through an edl file.
<definitions xmlns="http://schemas.oracle.com/events/edl" targetNamespace="'http://schemas.oracle.com/events/edl/EDNtest ">
<schema-import namespace="http://xmlns.geo.com/ns/Employee" location="xsd/Employee.xsd"/>
<event-definition name="createEmployee">
<content xmlns:ns0="http://xmlns.geo.com/ns/Employee" element="ns0:Employee"/>
</event-definition>
<event-definition name="removeEmployee">
<content xmlns:ns0="http://xmlns.geo.com/ns/Employee" element="ns0:Employee"/>
</event-definition>
</definitions>
Important thing to note is an event will be in its own namespace for example -“'http://schemas.oracle.com/events/edl/EDNtest” and the payload will have its own namespace - “http://xmlns.geo.com/ns/Employee”
There are a couple of tables and queues defined in SOAINFRA schema with the prefix EDN which are used as part of the event delivery system in SOA
There is an internal
code snippet on how to publish an event using SQL
call edn_internal_publish_event('http://schemas.oracle.com/events/edl/EDNtest','createEmployee','<business-event xmlns:ns1="http://schemas.oracle.com/events/edl/EDNtest'" xmlns="http://oracle.com/fabric/businessEvent">
<name>ns1:createEmployee</name>
<id>e4196227-806c-4680-a6b4-6f8df931b3f3</id>
<content>
<Employee xmlns="http://xmlns.geo.com/ns/Employee">
< EmpID>101</EmpID>
< Name>Geo Tho</ Name >
< Department>Engineering</Department >
</ Employee>
</content>
</business-event>
', 'R', null, null, '3')
First parameter will be the namespace of the event, second will be business event-definition name from edl file, third being the payload (business event tags are required), and sixth parameter being the priority. Hope this helps.