Test your SOA web services using SOAP UI tool
The SOAP UI tool is a
great tool that helps you to quickly test your web services. It is an easy to
use tool that makes your SOA testing fun and easy.
I recently had the opportunity to use it on one of my SOA
projects and it helped me a lot in debugging my web services. I had published
some web services that I had developed in .NET 3.5 using Windows
Communication Foundation (WCF) and this vendor company acted as the client
consuming those web services. The vendor was developing his client on J2EE
technology, possibly JSP/servlets web site.
During testing, the vendor told me that my web services were
throwing exceptions containing messages that I had wrapped in a fault contract.
The vendor’s development team just sent me the SOAP message that was causing my
web service to throw an exception. Here is how I used the SOAP message as an
input in the SOAP UI tool to call my web service method:
Create SOAP UI Project:
Launch your soapUI tool. Right click on the Projects option
in the left pane. Select the option of New soapUI Project.
Figure 1
Enter WSDL path:
Figure 2
By selecting the check box for Create sample requests for
all operations, the tool will automatically generate a sample request SOAP
message. Click on OK. The tool generates a sample web request as shown in
Figure 3:
Figure 3
Specify the SOAP message:
Double click on Request 1 and you will be able to see
the sample request created. I will copy-paste the SOAP message on the Request 1
pane, sent to me from the vendor’s development team:
Figure 4
Note in figure 4 that I have highlighted the
node in the SOAP message. The specifies
the fully qualified namespace of my service contract of IProductsService’s web
method of CreateProduct. The most important thing to note is .
Here you will specify the URL path of the test web service where you
have hosted. Since I need to debug the web service, I have launched it through
Visual Studio.NET: http://localhost:50911/ProductsService.svc
(I have also added xmlns:wsa="http://www.w3.org/2005/08/addressing"
as an attribute of , because apparently soapUI tool does
not add this by default).
Here is the SOAP request message:
<soap:Header>
<wsa:MessageID>urn:uuid:2161b61d-fe07-4cdb-a125-7b221100608awsa:MessageID>
<wsa:ReplyTo>
wsa:ReplyTo>
soap:Header>
<soap:Body>
<web:CreateProduct>
<web:productName>ABCweb:productName>
<web:productDescription>XYZweb:productDescription>
<web:productCode>5001web:productCode>
<web:company>ABCXYZweb:company>
web:CreateProduct>
soap:Body>
soap:Envelope>
Call the web service:
Call the web service by pressing on the green play button.
As you can see below the web service returns the following fault exception
response wrapped in a fault contract:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://WebServiceApp.ServiceContracts/IProductsService/CreateProductDefaultFaultContractFault>
<a:RelatesTo>urn:uuid:2161b61d-fe07-4cdb-a125-7b221100608aa:RelatesTo>
s:Header>
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Senders:Value>
s:Code>
<s:Reason>
<s:Text xml:lang="en-US">Product
code should be in the range of 1 to 500s:Text>
s:Reason>
<s:Detail>
<DefaultFaultContract xmlns="http://WebServiceApp.FaultContracts/2008/02" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
s:Detail>
s:Fault>
s:Body>
s:Envelope>
The vendor has specified the wrong product code. The web
service expects the product code to be in the range 1 to 500. After the
correcting the SOAP request message I specify product code 400 and consequently
get the following successful response message:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://WebServiceApp.ServiceContracts/IProductsService/CreateProductResponse>
<a:RelatesTo>urn:uuid:2161b61d-fe07-4cdb-a125-7b221100608aa:RelatesTo>
s:Header>
<s:Body>
<CreateProductResult>25CreateProductResult>
CreateProductResponse>
s:Body>
s:Envelope>
Although this example is quite trivial but in case if you
have large SOAP request messages having a lot of data fields, then the soapUI
tool comes quite handy.
1 Comments:
At 9:37 AM, Osama said…
Yeah its really cool! I use it too for testing my web services.
Post a Comment
<< Home