SOA / Web Services / Java

A Technology Blog

Posts Tagged ‘soapui’

Using SOAPUi to put/get message in/from IBM MQ

Posted by Vivek on July 8, 2014

We can use HermesJMS which provides out of the box feature to communicate with any of the messaging system. It comes with both soapUI open source and pro version. However, the drawback is message will contain JMS header and the responsibility of converting JMS to native header format lies with the developer/ tester. I have used IBM MQ as messaging system and in order to avoid any transformation from JMS to MQMD, I have used groovy to put and read messages.

Add a groovy test step to get hold of the XML message to be sent

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )

def holder = groovyUtils.getXmlHolder(“AddDiscussionBoardItem#Request”)

log.info holder.getXml()

def xml = holder.getXml()

//Connect to the queue manager

// Queue used for putting message

def propIQueue = testRunner.testCase.getProperty(“inputqueue”)

//Queue used for reading message

def propOQueue = testRunner.testCase.getProperty(“outputqueue”)

 //setting hostname

def propHostname = testRunner.testCase.getProperty(“hostname”) 

MQEnvironment.@hostname = propHostname.getValue()

 //setting port

def propPort = testRunner.testCase.getProperty(“port”)

MQEnvironment.@port = Integer.parseInt(propPort.getValue())                       

//setting Channel

def propChannel = testRunner.testCase.getProperty(“channel”)

MQEnvironment.@channel = propChannel.getValue()        

//setting Queue Manager

def propQM = testRunner.testCase.getProperty(“queuemanager”)

def queueManager = new MQQueueManager(propQM.getValue())

//Put message in queue

 def putMsg = new MQMessage();

int putOpenOpts = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;

def putQ = queueManager1.accessQueue(propIQueue.getValue(), putOpenOpts);

putMsg.writeString(xml);

def pmo = new MQPutMessageOptions();

putQ.put(putMsg, pmo);

putQ.close()

//Read message from queue

def getMsg = new MQMessage();

int getOpenOpts = MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_FIRST;

MQGetMessageOptions gmo=new MQGetMessageOptions();

def getQ = queueManager1.accessQueue(propOQueue.getValue(), getOpenOpts);

getQ.get(getMsg, gmo);

def response = getMsg.readString(getMsg.getMessageLength())

getQ.close()

Posted in Groovy, IBM Websphere Message Broker, IBM Websphere MQ | Tagged: , , | 1 Comment »

Testing ESB that choreographs web services

Posted by Vivek on March 28, 2010

It is not easy to test components of a service oriented architecture. Many people use the terms SOA and Web Services interchangeably and think that SOA cannot be implemented without web services.  However, this is not true. Web Service is just a way to implement SOA. There are projects which do not use web services but still inherit merits of a SOA. Grid Computing is one such example. So if you have a project where you have used an ESB to choreograph web services to achieve a desired functionality, then testing these web services (using a tool like SOAPUI etc) is not enough. One many not be interested only in testing the business functionality but also in testing the integration logic that resides within an ESB. This may not sound feasible as in most of the cases there are more than one webservice and each will accept input in a different format. So you cannot simulate all web services. But you definitely create a wrapper service that can accept request in any format and helps you  gauge whether your ESB has performed its job before invoking the service. Now what does a wrapper service do in this case:

1. No changes required in the ESB. Just a small configuration so that when you perform a dynamic lookup of end-point, the request is always directed to the wrapper service.

2. The wrapper service does not require implementing operations for each request. One operation that takes an Object as an input can serve the purpose.

3. A SOAP Handler that validates the SOAP Header and a function call from handleRequest method of SOAP Handler to validate the SOAP Body or message payload can be implemented.

4. No testing tools required. Leverage junit and xmlunit to perform assertion. Optionally, use APIs provided by SOAPUI to invoke test cases defined within your SOAP UI project to perform service validation.

Posted in SOA Testing | Tagged: , , , , | Leave a Comment »