Monday, November 20, 2017

AutoCompletion Search Box filtering data from a remote api using Angular 2

Getting Started

For this example I am going to use ngui which is collection of quality Angular2 directives.

To make ngui available to your project, you need to install a npm package "@ngui/ngui".

NPM Install

$ npm install @ngui/ngui --save

systemjs.config.js

map: {
  app: "app",
  ...

'@ngui/auto-complete':'node_modules/@ngui/auto-complete/dist/auto-complete.umd.js',
},

Import and include directives for your application

app.module.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent }  from './app.component';
import { FormsModule }  from '@angular/forms';
import { NguiAutoCompleteModule } from '@ngui/auto-complete';
import { HttpModule }      from '@angular/http';


@NgModule({
  imports:      [ BrowserModule,FormsModule ,NguiAutoCompleteModule,HttpModule],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

app.component.ts

import { Component,enableProdMode } from '@angular/core';

import { GetAPIs} from './getAPIS';


enableProdMode();

After importing all the modules as explained above, refer below sample codes which are cretaed inorder to create a simple auto completion search box which can filter data from a remote resource using HTTP calls.

app.component.ts

import { Component,enableProdMode } from '@angular/core';
import { GetAPIs} from './getAPIS';

enableProdMode();

@Component({
  selector: 'my-app',
  template: `<input ngui-auto-complete
  id="model4"
  [(ngModel)]="model4"
  placeholder="Enter the API(min. 2 chars)"
  [source]="arrayOfStrings"
  path-to-data="results"
  min-chars="2" />
<br/>selected api: {{model4 | json}}<br/><br/>`,
providers: [GetAPIs]
})
export class AppComponent {

  model1: any;
  arrayOfStrings: string[];
  //apis:{};
  constructor(private getAPIs: GetAPIs) {
    this.getAPIs.getAPIDetails().subscribe(arrayOfStrings => {this.arrayOfStrings=arrayOfStrings;});

  }

 
 }

getAPIS.ts (this class is the service class which calls the remote api using http calls and return the data to app.component.ts)

import {Injectable} from '@angular/core';
import {Http,Response} from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class GetAPIs{


    constructor(private http:Http)
    {
    }
getAPIDetails()
{

    return this.http.get('http://www.mocky.io/v2/5a12bd962c0000ba1dace740').map((res:Response)=>res.json());
}

    }


That's all you need to configure. Run the server, then you can see a similar search box as following.




Wednesday, June 21, 2017

Deploying connectors on ESB using admin services

Apart from deploying connectors through WSO2 ESB UI, you can use the AdminServices to deploy the connector. By default, the WSDLs of admin services are hidden from consumers. 

Follow the steps mentioned below to discover them.
  1. Set the <HideAdminServiceWSDLs> element to false in the <PRODUCT_HOME>/repository/conf/carbon.xml file.
  2. Restart the server.
  3. Start the WSO2 product with the -DosgiConsole option, such as sh <PRODUCT_HOME>/bin/wso2server.sh -DosgiConsole in Linux.
  4. When the server is started, hit the enter/return key several times to get the OSGI shell in the console.
  5. In the OSGI shell, type: osgi> listAdminServices

Step 1

Use “uploadLibrary” operation from https://localhost:9443/services/MediationLibraryUploader AdminService to upload the connector. The following sample curl request shows how to upload the connector zip file.


curl -k -v -H "Content-Type: application/soap+xml;charset=UTF-8;"  -H "SOAPAction:urn:getImport" --basic -u "admin:admin" --data @uploadLibrary.xml https://localhost:9443/services/MediationLibraryUploader
uploadLibrary.xml

uploadLibrary.xml

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:upl="http://upload.service.library.mediation.carbon.wso2.org" xmlns:xsd="http://upload.service.library.mediation.carbon.wso2.org/xsd">
   <soap:Header/>
   <soap:Body>
      <upl:uploadLibrary>
         <upl:fileItems>
            <xsd:dataHandler>{BASE64_ENCODED_ZIP_CONTENT}</xsd:dataHandler>
            <xsd:fileName>fileconnector-connector-2.0.7.zip</xsd:fileName>
            <xsd:fileType>zip</xsd:fileType>
         </upl:fileItems>
      </upl:uploadLibrary>
   </soap:Body>
</soap:Envelope>

Step 2

Once you upload the connector, use the following command to add the import file into repository/deployment/server/synapse-configs/default/imports.


curl -k -v -H "Content-Type: application/soap+xml;charset=UTF-8;"  -H "SOAPAction:urn:addImport" --basic -u "admin:admin" --data @addImport.xml https://localhost:9443/services/MediationLibraryAdminService
addImport.xml


addImport.xml





<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://org.apache.synapse/xsd">
   <soap:Header/>
   <soap:Body>
      <xsd:addImport>
         <xsd:libName>fileconnector</xsd:libName>
         <xsd:packageName>org.wso2.carbon.connector</xsd:packageName>
      </xsd:addImport>
   </soap:Body>
</soap:Envelope>


Step 3

Then, enable the connector using the following command:


curl -k -v -H "Content-Type: application/soap+xml;charset=UTF-8;"  -H "SOAPAction:urn:updateStatus" --basic -u "admin:admin" --data @updateStatus.xml https://localhost:9443/services/MediationLibraryAdminService
updateStatus.xml


updateStatus.xml




<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://org.apache.synapse/xsd">
   <soap:Header/>
   <soap:Body>
      <xsd:updateStatus>
         <xsd:libQName>{org.wso2.carbon.connector}fileconnector</xsd:libQName>
         <xsd:libName>fileconnector</xsd:libName>
         <xsd:packageName>org.wso2.carbon.connector</xsd:packageName>
         <xsd:status>enabled</xsd:status>
      </xsd:updateStatus>
   </soap:Body>
</soap:Envelope>

That's all. Now you can call operations which supports from the connector inside your proxy.

Thanks.

Tuesday, June 6, 2017

What to do when you get "java.lang.OutOfMemoryError: PermGen space " issue once you login WSO2EI 6.1.1

After the successful start of the WSO2 Enterprise Integrator (EI) 6.1.1, I tried to log in the management console and encountered an error java.lang.OutOfMemoryErrorPermGenspace [1]. 

[1] java.lang.OutOfMemoryError: PermGen space
Dumping heap to /home/sa/Desktop/sachini/PROD-7/wso2ei-6.1.1/repository/logs/heap-dump.hprof ...
Unable to create /home/sa/Desktop/sachini/PROD-7/wso2ei-6.1.1/repository/logs/heap-dump.hprof: File exists
SEVERE:Memory usage is low, parachute is non existent, your system may start failing.
Exception in thread "http-nio-9443-exec-13" 
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "http-nio-9443-exec-13"
Exception in thread "PoolCleaner[1007456727:1496813475907]" 

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "PoolCleaner[1007456727:1496813475907]"


Please follow the steps to solve the issue.

  1. Open /wso2ei-6.1.1/bin/integrator.sh
  2.  Add the below value under "$JAVA_OPTS \ "             
            -Xms256m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m \

That's all.Once you restart the server you will be able to log to EI 6.1.1

 

Monday, April 3, 2017

Mutual SSL (Two way SSL) with WSO2 Enterprise Service Bus

This article gives a brief explanation about how we can make WSO2 ESB 5.0.0 for Mutual SSL Communication

Here is a  diagram which gives you a clear idea about how mutual SSL communication happens.


We can define 4 steps for mutual SSL communication.

(1) Client says hello and request for the Server certificate
(2) Server says hello with the certificate

That is the first handshake that happens , but when you enable mutual SSL there is a another handshake happens.

(3) Server says hello with requesting for the client certificate
(4) Client says hello back with the certificate

ONCE BOTH THE PARTIES TRUST EACH OTHER THEY ESTABLISH THE CONNECTION FOR FURTHER ACTIONS BETWEEN CLIENT AND THE SERVER.

FOR THE CLIENT TO TRUST THE SERVER

Client trust store should have the CA certificate / server certificate - signed by CA of the server

FOR SERVER TO TRUST THE CLIENT

 Server trust store should contain the CA certificate / client certificate - signed by CA of the client

Lets move on to a sample which shows how mutual SSL can be configured in WSO2 ESB 5.0.0

To demonstrate we have two ESB servers, one is acting as the client and other one is backend.

Steps need to be done in client ESB server


Navigate to wso2esb-5.0.0/repository/resources/security in client server ESB and use following commands

Step 1 : Create a Keystore


keytool -genkey -alias partner1 -keyalg RSA -keysize 4096 -keystore partner1_keystore.jks -dname "C=LK,ST=WP,L=Colombo,O=WSO2,OU=Carbon,CN=partner1.com" -storepass partner1 -keypass partner1 

Step 2 : Create a certificate signing request


keytool -certreq -alias partner1 -file partner1certreq.csr -keystore partner1_keystore.jks -storepass partner1 -keypass partner1


Step 3 : Create a private key using passphrase


openssl genrsa -des3 -passout pass:capassword -out ca.key 4096


Step 4 : Create the CA certificate using the private key


openssl req -new -x509 -extensions v3_ca -key ca.key -passin pass:capassword -out ca.crt -days 365 -subj "/C=LK/ST=WP/L=Colombo/O=WSO2/OU=Carbon/CN=caauthority"


Step 5 : Sign the CSR using CA Certificate


openssl x509 -req -days 365 -in partner1certreq.csr -CA ca.crt -CAkey ca.key -passin pass:capassword -set_serial 559823400 -out partner1signedcert.crt


Now we need to import the partner1signedcert.crt to created new keystore (partner1_keystore.jks). When importing as we have signed the certificate using our own created CA, first we need to import the CA certificate to keystore then only we can load the partner1signedcert.crt.

Step 6 : Import ca certificate to keystore


keytool -import -trustcacerts -alias ca1 -file ca.crt -keystore partner1_keystore.jks -storepass partner1


Step 7 :Import signed certificate to keystore


keytool -import -v -alias partner1 -file partner1signedcert.crt -keystore partner1_keystore.jks -keypass partner1 -storepass partner1


Step 8 :By using below command you can see whether the certificates are added to the keystore 


keytool -list -v -keystore partner1_keystore.jks -storepass partner1

Steps need to be done in Backend ESB server

Navigate to wso2esb-5.0.0/repository/resources/security in backend server ESB and use following commands

Step 1 : Create a Keystore


keytool -genkey -alias partner2 -keyalg RSA -keysize 4096 -keystore partner2_keystore.jks -dname "C=LK,ST=WP,L=Colombo,O=WSO2,OU=Carbon,CN=partner2.com" -storepass partner2 -keypass partner2


Step 2 : Create a certificate signing request


keytool -certreq -alias partner2 -file partner2certreq.csr -keystore partner2_keystore.jks -storepass partner2 -keypass partner2


Step 3 : Create a private key using passphrase


openssl genrsa -des3 -passout pass:capassword -out ca2.key 4096


Step 4 : Create the CA certificate using the private key


openssl req -new -x509 -extensions v3_ca -key ca2.key -passin pass:capassword -out ca2.crt -days 365 -subj "/C=LK/ST=WP/L=Colombo/O=WSO2/OU=Carbon/CN=caauthority"

Step 5 : Sign the CSR using CA Certificate


openssl x509 -req -days 365 -in partner2certreq.csr -CA ca2.crt -CAkey ca2.key -passin pass:capassword -set_serial 559823400 -out partner2signedcert.crt


Step 6 : Import ca certificate to keystore


keytool -import -trustcacerts -alias ca2 -file ca2.crt -keystore partner2_keystore.jks -storepass partner2


Step 7 : Import signed certificate to keystore


keytool -import -v -alias partner2 -file partner2signedcert.crt -keystore partner2_keystore.jks -keypass partner2 -storepass partner2


Now we have created two new keystores and added the two certificates generated to the keystores separately in client and server ESB servers.

Now we need to exchange the certificates between client and server inorder to create a mutual SSL communication. So we need to import ca.crt and partner1signedcert.crt to server ESB trust store and need to import ca2.crt and partner2signedcert.crt to client ESB trust store.

In Client Side


keytool -import -v -alias partner2 -file partner2signedcert.crt -keystore client-truststore.jks -keypass wso2carbon -storepass wso2carbon


keytool -import -trustcacerts -alias ca2 -file ca2.crt -keystore client-truststore.jks -storepass wso2carbon


In server side


keytool -import -trustcacerts -alias ca1 -file ca.crt -keystore client-truststore.jks -storepass wso2carbon


keytool -import -v -alias partner1 -file partner1signedcert.crt -keystore client-truststore.jks -keypass wso2carbon -storepass wso2carbon


That's all you need to do.  Restart the two server with after enable SSL logs.

To enable the SSL logs use below command:


sh wso2server.sh -Djavax.net.debug=all

Create a proxy in client side  ESB and provide the back end ESB server service url as endpoint url in send mediator of the created proxy in client ESB server.

Then once you send the request to client ESB, you can see that certificates are shared between two ESB servers and started the Mutual SSL communication between client and backend ESB servers.

Hope you got an idea about Mutual SSL communication WSO2 ESB.

Thanks.

Tuesday, March 21, 2017

How to communicate a custom mediator error to the end user

You can use the Class mediator and custom mediators for user-specific custom developments when there is no built-in mediator that already provides the required functionality.Let's assume that in my custom mediator if an error occurs while mediating,I log an error and break the mediation chain by returning false in mediate() . However, I'd like to communicate it to the end user (which knows nothing about logs) such that he received the error text in the HTTP response.

Here is a sample custom mediator which I created to achieve that requirement. I’ve added comments for you to understand the code.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.sachini;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.synapse.Mediator;
import org.apache.synapse.MessageContext;
import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.llom.OMTextImpl;
import org.apache.axiom.om.util.AXIOMUtil;
import org.apache.axiom.soap.SOAPBody;

import javax.xml.stream.XMLStreamException;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axis2.AxisFault;

public class SampleMediator extends AbstractMediator {
 private String myname = "";
 private String sequenceKey = "customFaultSeq";
 public String getMyname() {
  return myname;
 }
 public void setMyname(String myname) {
  this.myname = myname;
 }
 public boolean mediate(MessageContext context) {
  // TODO Implement your mediation logic here 
  System.out.println("**myname ****" + myname);
  if (myname.equalsIgnoreCase("sachini")) {
   System.out.println(myname + "***inside true***");
   return true;
  }

  else {
   System.out.println("***inside false***");
   //Get the axis2MessageContext synapse message context
   org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) context).getAxis2MessageContext();

   //Get Current Envelop       
   SOAPEnvelope axisMsgEnvelope = axis2MessageContext.getEnvelope();
   //Create the custom message which you need to send to enduser
   OMElement customPayloadElement = null;
   String customErrorMessage = "There is an error in your mediation flow";
   //Add the created custom message to context
   try {
    customPayloadElement = AXIOMUtil.stringToOM("<text>" + "<![CDATA[" + customErrorMessage + "]]>" + "</text>");
    context.setEnvelope(createSOAPEnvelope(customPayloadElement));
   } catch(XMLStreamException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   } catch(AxisFault e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
   //call the sequence created as customFaultSeq inside ESB
   Mediator sequenceMediatorToInvoke = null;
   if (sequenceKey != null) {
    sequenceMediatorToInvoke = context.getSequence("customFaultSeq");
   } else {
    if (log.isDebugEnabled()) {
     log.debug("Sequence Key not specified.");
    }
   }
   //pass the created message to the customFaultSeq
   sequenceMediatorToInvoke.mediate(context);

   return false;

  }

 }
 private SOAPEnvelope createSOAPEnvelope(OMElement documentElement) {
  SOAPEnvelope envelope;
  SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
  envelope = soapFactory.getDefaultEnvelope();
  if (documentElement != null) {
   envelope.getBody().addChild(documentElement);
  }
  return envelope;
 }
}

Here is the proxy service which invoke the custom mediator

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="SacProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <log level="full"/>
         <property name="myname" value="sachini" scope="default" type="STRING"/>
         <class name="com.sachini.SampleMediator">
            <property name="myname" value="madhu"/>
         </class>
         <log level="custom">
            <property name="afterClass" value="**afterClass***"/>
         </log>
         <log level="full"/>
      </inSequence>
   </target>
   <description/>
</proxy>
                                

Here is the Custom Fault Sequence which is getting hit when there is an error of mediation in my custom mediator


1
2
3
4
5
6
7
8
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="customFaultSeq" xmlns="http://ws.apache.org/ns/synapse">
    <log level="custom">
        <property name="prop1" value="**inside customFault***"/>
    </log>
    <log level="full"/>
    <respond/>
</sequence>

Here is the response I got through SOAP UI once I invoke the proxy. We are getting our custom error message as HTTP response in our enduser side.



Thanks.

Sunday, February 19, 2017

Customize the response header "Server: WSO2-PassThrough-HTTP" in WSO2

In some scenarios you want to customize the Server header which is going out from the ESB. By default inside ESB, it is setting  the Server header to WSO2-PassThrough-HTTP [1].

[1]

[2017-02-17 13:18:14,920] DEBUG - wire << "HTTP/1.1 200 OK[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "RevokedAccessToken: wV4dUQ4HGHiNbsb2zIFKmMftLqEa[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "AuthorizedUser: admin[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "Content-Type: text/html[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "Pragma: no-cache[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "Cache-Control: no-store[\r][\n]"
[2017-02-17 13:18:14,920] DEBUG - wire << "Date: Fri, 17 Feb 2017 07:48:14 GMT[\r][\n]"
[2017-02-17 13:18:14,921] DEBUG - wire << "Server: WSO2-PassThrough-HTTP[\r][\n]"
[2017-02-17 13:18:14,921] DEBUG - wire << "Transfer-Encoding: chunked[\r][\n]"
[2017-02-17 13:18:14,921] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
[2017-02-17 13:18:14,921] DEBUG - wire << "[\r][\n]"
[2017-02-17 13:18:14,923] DEBUG - wire << "0[\r][\n]"
[2017-02-17 13:18:14,923] DEBUG - wire << "[\r][\n]"

Lets assume that need to customize the server header from "WSO2-PassThrough-HTTP" to "MyServerHeader" as bellow which coming with the response.

Server: MyServerHeader

Then you need to add the http.origin-server to passthru-http.properties file located in ESB_HOME/repository/conf/ directory with customized value as bellow.


http.origin-server=MyServerHeader

Once you restart the server, the response will be changed as bellow with the changed server header.


[2017-02-17 13:34:14,867] DEBUG - wire << "HTTP/1.1 200 OK[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Via: 1.1 vegur[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Content-Type: text/plain; charset=utf-8[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Date: Fri, 17 Feb 2017 08:04:14 GMT[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Server: MyServerHeader[\r][\n]"
[2017-02-17 13:34:14,867] DEBUG - wire << "Transfer-Encoding: chunked[\r][\n]"
[2017-02-17 13:34:14,868] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
[2017-02-17 13:34:14,868] DEBUG - wire << "[\r][\n]"
[2017-02-17 13:34:14,869] DEBUG - wire << "a[\r][\n]"
[2017-02-17 13:34:14,870] DEBUG - wire << "responseee[\r][\n]"
[2017-02-17 13:34:14,870] DEBUG - wire << "0[\r][\n]"
[2017-02-17 13:34:14,870] DEBUG - wire << "[\r][\n]"

Thanks.

Sending SOH character at the beginning of a message in wso2

In here we are going append the SOH (Start Of Heading) character to our incoming message to WSO2 ESB, and send the payload with the SOH character to the Backend.

For that you need to write a class mediator which appends the SOH and payload, then send to the back end. In this example we are going to the send the payload with SOH to IBMMQ server (which we consider as our BE).

Step 1

Create the class mediator as following


package com.home;

import com.ibm.mq.jms.JMSC;
import com.ibm.mq.jms.MQQueue;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;

import javax.jms.*;

public class SOHCustomMediator extends AbstractMediator {

    public boolean mediate(MessageContext messageContext) {
        try {

            String sohCharactor = (String) messageContext.getProperty("regProperty");
            String messageBody = (String) messageContext.getProperty("messagebody");

            //======================================================

            MQQueueConnectionFactory queueConnectionFactory = new MQQueueConnectionFactory();
            //Configure the connection properties
            queueConnectionFactory.setHostName ("localhost");
            queueConnectionFactory.setPort (1414);
            queueConnectionFactory.setQueueManager ("ESBQManager");
            queueConnectionFactory.setChannel ("mychannel");
            queueConnectionFactory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
            //  Started the queue connection
            QueueConnection queueConnection = queueConnectionFactory.createQueueConnection ("mqm", "1qaz2wsx@");
            queueConnection.start();
            // Set JMS configuration for queue and session
            Queue queue = new MQQueue("LocalQueue1");
            QueueSession session = queueConnection.createQueueSession (false, Session.AUTO_ACKNOWLEDGE);
            QueueSender sender = session.createSender (queue);
            //Con-cat the message and the SOH
            TextMessage message = session.createTextMessage(sohCharactor + messageBody);
            message.setStringProperty("MyCustomProperty", "DUMMY_PROPERTY_VALUE");
            System.err.println("Sending message:" + message.getText());
            sender.send (message);
            System.out.println ("sent message: " + message);
            //close the session and connection
            session.close();
            queueConnection.close();


        } catch (Exception e) {
            e.printStackTrace();
        } finally {

        }
        return true;
    }
}

Step 2

Store the SOH.txt in the ESB registry (gov:trunk/SOH.txt)

Step 3

Add below jar files to <ESB_HOME>/repository/components/lib folder. Because those are needed for the class mediator to send the message to the IBM MQ.


  • com.ibm.dhbcore.jar
  • com.ibm.mq.jar
  • com.ibm.mqjms.jar
  • com.ibm.mq.soap.jar
  • com.ibm.msg.client.osgi.wmq_7.0.1.3.jar

Step 4

Here is the sample proxy which is setting the SOH character and message payload to properties and then call the class mediator.


<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="SOHProxy"
       startOnLoad="true"
       statistics="disable"
       trace="disable">
   <target>
      <inSequence>
         <log level="full"/>
         <property expression="json-eval($)" name="messagebody"/>
         <property expression="get-property('registry', 'gov:trunk/SOH.txt')"
                   name="regProperty"/>
         <class name="com.home.SOHCustomMediator"/>
      </inSequence>
   </target>
   <description/>
</proxy>


That's all you need to do.

Thank You.


Blogger Widgets