Hi,

Jay SenSharma

Jay SenSharma

Here is a very simple demonstration of Debugging WebService related issues using one of the Best Debugging utility “SOAPUI”. I have found this tool as a Best tool to debug, analyze and understand WebServices. We can download SOAPUI from the following link: http://www.eviware.com/Download-soapUI/download-soapui-pro.html . I am using the trial verson of this tool. I have downloaded the Windows version of this installer which is in ZIP format (soapui-pro-3.5.1-windows-bin.zip) …so Just download it …extract it and Start Using it.

NOTE: all the features will not available with this Utiltiy without having a Valid License.

In the following demonstration we will create a Simplest WebService and then we will use the SOAPUI utility to send the request to the WebService as well as we will get the response back from the Serice inside the Great SOAPUI Editor.

Step1). Create a Directory some where in your File System “C:SOAP_UI” download and extract the “soapui-pro-3.5.1-windows-bin.zip” here. You will see the following Directory structutre now:

Step2). Now we are going to start a Simplest Test Webservice Creation … Create a Directory “TestWebService” inside “C:SOAP_UI”

Step3). Now create “src” directory inside “C:SOAP_UITestWebService”

Step4). Now start writing the WebService “HelloWorldImpl.java” inside “C:SOAP_UITestWebServicesrc” like follwoing:

package ws;
import javax.jws.WebService;
@WebService(name="HelloWorldPortType", serviceName="HelloWorldService")
public class HelloWorldImpl
{
public String sayHelloWorld(String message)
{
System.out.println("sayHelloWorld:" + message);
return "Here is the message: '" + message + "'";
}
}

Step5). Now create a “TestClient.java” program which will work as a webserice client.

package client;
public class TestClient
{
public static void main(String ar[]) throws Exception
{
HelloWorldService service=new HelloWorldService_Impl();
HelloWorldPortType port=service.getHelloWorldPortTypeSoapPort();
String result=port.sayHelloWorld(ar[0]);
System.out.println("nnt WebService Returned: "+result);
}
}

Step6). Now create a “build.xml” Ant script inside “C:SOAP_UITestWebService” like following to build and deploy the WebService and to run the testClient in one GO…

<project name="webservices-hello_world" default="all">
<!-- set global properties for this build -->
<property name="wls.username" value="weblogic" />
<property name="wls.password" value="weblogic" />
<property name="wls.hostname" value="localhost" />
<property name="wls.port" value="7001" />
<property name="wls.server.name" value="AdminServer" />
<property name="ear.deployed.name" value="helloWorldEar" />
<property name="example-output" value="output" />
<property name="ear-dir" value="${example-output}/helloWorldEar" />
<property name="clientclass-dir" value="${example-output}/clientclasses"/>

<path id="client.class.path">
     <pathelement path="${clientclass-dir}"/>
     <pathelement path="${java.class.path}"/>
</path>

<taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask" />
<taskdef name="clientgen" classname="weblogic.wsee.tools.anttasks.ClientGenTask" />
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy"/>

<target name="all" depends="clean,build-service,deploy,client,run" />

<target name="clean" depends="undeploy">
     <delete dir="${example-output}"/>
</target>

<target name="build-service">
    <jwsc srcdir="src" destdir="${ear-dir}">
     <jws file="HelloWorldImpl.java" />
    </jwsc>
</target>

<target name="deploy">
<wldeploy action="deploy" name="${ear.deployed.name}" source="${ear-dir}"
          user="${wls.username}" password="${wls.password}" verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}"
          targets="${wls.server.name}" />
</target>

<target name="undeploy">
<wldeploy action="undeploy" name="${ear.deployed.name}"
          failonerror="false" user="${wls.username}" password="${wls.password}"
          verbose="true" adminurl="t3://${wls.hostname}:${wls.port}"
          targets="${wls.server.name}" />
</target>

<target name="client">
<clientgen  wsdl="http://${wls.hostname}:${wls.port}/HelloWorldImpl/HelloWorldImpl?WSDL"
            destDir="${clientclass-dir}"
            packageName="client"/>
   <javac srcdir="${clientclass-dir}" destdir="${clientclass-dir}" includes="**/*.java"/>
   <javac srcdir="src" destdir="${clientclass-dir}" includes="client/**/*.java"/>
</target>

<target name="run">
    <javac srcdir="src" destdir="${clientclass-dir}" includes="TestClient.java"/>
    <java classname="client.TestClient" fork="true" failonerror="true" >
         <classpath refid="client.class.path"/>
         <arg line="'Jay SenSharma'" />
    </java>
</target>
</project>

Step7). Now run the “setWlsEnv.cmd” to set the CLASSPATH and PATH properly in our command prompt…

running the setWLSEnv.cmd to set CLASSPATH/PATH

running the setWLSEnv.cmd to set CLASSPATH/PATH

Step8). Run the ANT script to build, deploy and run the WebService in one GO…

Building WebService using ANT Script for SOAP UI Test

Building WebService using ANT Script for SOAP UI Test

Running WebService before testing it using SOAPUI

Step9). Now please follow the below Steps in order to test/debug the WebService from the SOAP UI …

setting JAVA_HOME before starting SOAPUI

starting SOAPUI using the "soapui-pro.bat" file

Creating a SOAPUI Project --1

Creating a SOAPUI Project--2

Creating a SOAPUI Project--2

Creating a SOAP Request in SOAPUI

Creating a SOAP Request in SOAPUI

sending SOAPUI created SOAP Request

sending SOAPUI created SOAP Request

Getting SOAP Response from WebService in SOAPUI editor

Above is just a basic introduction of SOAP UI …you can explore it more.
.
.
Thanks
Jay SenSharma

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.