Working with XSLT Service Engine: Part 2

Project summary: In This project, I am going to do xml to xml transformation using Service Bridge. Please Check working with XSLT Service Engine Part 1 for more details about XSLT Service engine and sample project for Request-Reply service of XSLT service Engine. In this sample project I am going to take customer information like Name , Address , Personal Data in separate node and then merge all above info in single node. Creating Sample Project Using   Service Bridge (xml to xml transformation) In Service Bridge we can apply multiple xml transformation on request xml and then send output back to source. We need to have same number of wsdl operation as number of transformation we want to do. In this project I am going to apply two xml transformations. So I need to create two wsdl as webservice operation to perform transformation. Let’s  say Request1 and response 1 – first operation Request2 and response 2 – second operation Client will send request via request 1 and response 1 will get back to client but over all process will something like this . (Client input xml)Request1–>apply xsl on input to generate request2–>  request 2àappy xsl on request 2 generate response 2–>  response 2 –> apply xsl on response2 to generate response1 –> response 1(client output xml). Create XSLT Module: Please refer to part 1 for details to create XSLT module. Create XSD for request and reply operation <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xml.netbeans.org/schema/CustomerDetails" xmlns:tns="http://xml.netbeans.org/schema/CustomerDetails" elementFormDefault="qualified"> <xsd:complexType name="CustomerName"> <xsd:sequence> <xsd:element name="firstName" type="xsd:string"/> <xsd:element name="lastName" type="xsd:string"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="CustomerAddress"> <xsd:sequence> <xsd:element name="HomeAddress"/> <xsd:element name="OfficeAddress"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="PersonalData"> <xsd:sequence> <xsd:element name="gender" type="xsd:string"/> <xsd:element...

Working With XSLT Service Engine: Part 1

About the XSLT Service Engine The XSLT Service Engine is a Java-based transformation engine that is used to convert XML documents from one data format to another. The XSLT Service Engine makes it easier for users to configure and expose XSL style sheets as web services. Using the XSLT Service Engine requires no special knowledge of XSL, but rather allows any XSL style sheet to be deployed as a JBI service unit. The XSLT Service Engine is not solely responsible for performing transformations. XSL style sheets implement a web service operation (as normally defined in a WSDL). When deployed as JBI service units, these service units correspond to a service endpoint. Each endpoint is activated when the XSLT service unit is deployed. In a sense, the XSLT Service Engine is a container of XSL style sheets, each of which represents a service endpoint in the JBI environment. The following steps highlight the life cycle of a typical message using the XSLT Service Engine: The XSLT service unit is configured with service endpoint information. The service unit is deplopyed, along with the XSL style sheet, to the JBI environment. The XSLT Service Engine compiles the style sheet. A message arrives and the XSLT Service Engine searches for the service endpoint responsible for handling the message. The message is transformed using the service endpoint’s XSL style sheet. A response is sent back via the Normalized Message Router (NMR). XSLT Service Engine Features The XSLT Service Engine supports the following use cases: Request-Reply Service Request-Reply is a standard request-reply scenario. An XML message request is transformed and the result is sent back...

Running Apache Camel in OpenESB – Part 2

In my previous post, I gave a step by step guide on running your first camel application in OpenESB. This entry is continuation to that it shows how to invoke an outbound JBI call from Camel. We will modify the same application to send message to a Glassfish’s JMS Queue instead of ActiveMQ’s queue. 1. To send a message to Glassfish’s Queue, we need a create JMS Binding WSDL Create a WSDL using the Wizard and select JMS Binding. Follow the wizard to provide a queue name, access details, etc. The WSDL should be created in CamelCompAppJBIModule1 project in default package. Choose the jbi2camel.xsd and select input element as msg:AnyMessage. Below is the types part and message part from the wsdl: <types> <xsd:schema targetNamespace="http://openesb.org/jbi2camel/CamelJBIModule1"> <xsd:import schemaLocation="jbi2camel.xsd" namespace="http://openesb.org/jbi2camel/message/CamelJBIModule1"/> </xsd:schema> </types> <message name="JMSInputMessage"> <part name="part1" element="msg:AnyMessag"/> </message> 2. Edit the jbi.xml in CamelCompAppJBIModule1 project to add the consumes element: <consumes service-name="JMSOutService" endpoint-name="jmsTestQueue_OutPort" interface-name="jms:JMSOutPortType" > </consumes> Make sure the service-name, endpoint-name, interface-name are the same ones from the newly created JMS wsdl. 3.  Edit the AppRouteBuilder.java as below:   public void configure() { String jbiJMSTestQueue = "jbi:http://j2ee.netbeans.org/wsdl/CamelJBIModule1/src/jmsTestQueue/JMSOutService/jmsTestQueue_OutPort"; //(A) String jbiURI = "jbi:http://openesb.org/jbi2camel/CamelJBIModule1/CamelJBIModule1_service/jbi2camel_endpoint"; //(B) from(jbiURI).process(new Processor() { //(C) public void process(Exchange exchng) throws Exception { Message inMessage = exchng.getIn(); String strInMsg = inMessage.getBody(String.class); System.out.println("Received in Processor : " + strInMsg); String strOutMsg = strInMsg.replace("My String", "MyReply"); exchng.getOut().setBody(strOutMsg); // (D) }}).to(jbiJMSTestQueue); //(E) } A) The variable “jbiJMSTestQueue” refers to the JMS WSDL’s endpoint. This URL is constructed by concatenating namespace, service name, port name. E). This line sends the message to the new JMS Queue. 4) Right click on Service Assembly node and “Clean” it....