SOA / Web Services / Java

A Technology Blog

Posts Tagged ‘soamoa’

SOAMOA – New kid in the block

Posted by Vivek on May 15, 2010

This is just an extension to my previous post (SOA Testing). Most of the java developers look to automate web service testing. If you are using SOAPUI, this is possible by writing junit test cases and then invoking SOAPUi projects from junit for a particular test case. It might be the case that you do not want to rely on any tool while testing and end up creating test cases that creates and invokes request for you. With the same intention, I was looking for a free tool and found this one – SOAMOA.

Still in its infancy stage, this tool may not be used for all your testing needs but some features look promising. The GUI is not too great. It doesn’t offer you to set preferences and does not support web services standards. For all this, you already have a free tool SOAPUI (not the pro version). The only striking feature is the ability to generate junit test cases and groovy script based upon your request. You just need to import your WSDL and create SOAP Request as you generally do in SOAPUI. 

If you have a request, for eg.

<SOAP-ENV:Envelope xmlns:SOAP-ENV=”“>
    <SOAP-ENV:Body xmlns:web=”“>
                <company>hell techologies</company>

Creating Groovy Script for the request will produce the following:

/* Generated GroovyWS Script by SoaMoa, :vivek at Sat May 15 10:53:13 GMT+05:30 2010 */


def proxy = new WSClient(“file:/C:/…../WEB-INF/wsdl/EmployeeService.wsdl”, this.class.classLoader)
def arg0 = proxy.create(“com.employee.service.webservices.GetEmployeeDetailRequest”)
arg0.employeeId = 2000
arg0.employeeName = ‘Monster’ = ‘hell technologies’
def getEmployeeDetailResponse = proxy.getEmployeeDetail(arg0)

A junit class will look like:

/* Generated Testcase by SoaMoa, :vivek at Sat May 15 10:59:54 GMT+05:30 2010 */

import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;

import java.util.Iterator;

import junit.framework.TestCase;

public class GetEmployeeDetailTest extends TestCase {
public void testGetEmployeeDetail() throws Exception {
String endpointURL = “
QName serviceName = new QName(““, “EmployeeService”);
QName portName = new QName(““, “EmployeeServiceWSPort”);
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointURL);
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
MessageFactory messagefactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
SOAPMessage request = messagefactory.createMessage();
SOAPPart part = request.getSOAPPart();
SOAPEnvelope env = part.getEnvelope();
SOAPBody body = env.getBody();

body.addNamespaceDeclaration(“web”, ““);
    SOAPElement getEmployeeDetail = body.addChildElement(“getEmployeeDetail”, “web”);
        SOAPElement arg0 = getEmployeeDetail.addChildElement(“arg0”);
            SOAPElement employeeId = arg0.addChildElement(“employeeId”);
            SOAPElement employeeName = arg0.addChildElement(“employeeName”);
            SOAPElement company = arg0.addChildElement(“company”);
            EmployeeId.addTextNode(“Hell Technologies”);           

SOAPMessage response = dispatch.invoke(request);
SOAPBody replyBody = response.getSOAPBody();



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