Showing posts with label SoapUI. Show all posts
Showing posts with label SoapUI. Show all posts

Monday, July 13, 2015

In this post I will explain you how to add a delay to a response when working with mock services in SOAPUI. This is quit simple, in-order to create a SOAP UI mock service you follow this guide. After creating a mock service do the following to add a delay to the response.

1. Open The mock service and click on the specific action  and open the response tab as shown below.



2. Now from dispatch option select Script option.


3. Now add the following code to the content. Please note that I'm using groovy as the scripting language and you can change this from settings.

Thread.sleep(5000)





You can change the delay by changing the value note that the value is specified in milliseconds. This will add a delay to the response. :)



Saturday, May 9, 2015

Hi all, in this post I will explain you how to create a mock service to mimic a SOAP backend using SOAP UI. It is really easy and straight forward to do. In order to make things super easy and simple I'll be using WSO2 ESBs echo service as the base service (Just to create the structure of the service). Or you can use any existing SOAP service as you wish.

1. Login to WSO2 ESB and navigate to to Service ==> List and click on WSDL 1.1 link of the echo service and copy the URL of the WSDL. e.g: http://localhost:8280/services/echo?wsdl




2. Now Open SOAP UI and Click on File menu and select New SOAP project, now add the copied WSDL URL as shown below and click on OK.




3. Now the Project will be created. Now right click on echosoap  service and select New SOAP Mock Service.




4. Now you can select the necessary operations and define the context path of the SOAP service you are creating. After changing the fields click on OK.



5. Now if you click on any of the operations you can customize the WSDL Operations and Name and the Description.

6. Now in-order to specify the response you need to send to the client, click on the Response 1. It will open a new window. You can add the Intended response body. Refer the below image.



7. Now double click on the Mock Service and click on the green arrow to start the Mock Service.




8. After starting the mock service you can test it by changing the endpoint of the echo service as shown below. As you can see it will give you the expected output.



There are advance features included in SOAP UI where you can script and do complex customization to the mock service. You can play with these and see what can be done.

Hope this will help someone interested. Please drop a comment if you have any queries.

Sunday, May 25, 2014

Hi, this is the part two of the article where we are creating a complete AXIOM based web service with Axis2, If you haven't read the part one, please read it before going through this.

In this Post I will try to cover as much as possible regarding testing your webservice with SoapUI.

I will be using SoapUI 5.0 installed on top of Ubuntu 14.04.

Ok So lets begin.

What is SoapUI


SoapUI is a free tool that can be used to test web services.  SoapUI can test SOAP and REST based web services, JMS, AMF, as well as make any HTTP(S) and JDBC calls. Learn more from here.

Prerequisites


Install SoapUI on your PC, this can be done in two ways, Install SoapUI as a standalone Application or as a IDE plugin, I recommend to install this as a separate application.

Deploy your webservice created in part 1 and check whether it is deployed correctly as mentioned in that post.

Testing Your Service

Step 01

  1. Go to the Axis2 server URL and check whether the service is available. in my case the Axis2 services can be found at "http://localhost:8080/axis2/services/" 
  2. Click on the title of your service and you will be shown the WSDL of your service.


Note : The "wsdl" function following the service name will give you the WSDL of the service.

  1. Copy the url of the WSDL. 

Step 02

  1. Open SoapUI  and go to File >>> New SOAP Project.

  1. Then give an appropriate name to the project and paste the link of the WSDL of your service as shown in the following image and click OK.


  1. Now your project will be created with all service methods of your service. Note that Soap Binding 1.1 and 1.2 are automatically created by SoapUI.


  1. First lets test the "setProduct" method. Select the request which is located under setProduct method in the Soap1.1 Binding option as shown below.

  1. As you can see from the above image the full message or the payload that has to be sent to the service is not auto generated, as denoted by the "?" the necessary content has to placed in the marked position.
 Note that the message that the service expect is as following,


1
2
3
4
5
6
<tns:setProduct xmlns:tns="http://myshop.com/xsd">
   <tns:id>1</tns:id>
   <tns:model>Samsung</tns:model>
   <tns:price>100</tns:price>
   <tns:qty>6</tns:qty>
</tns:setProduct>

So lets add the required content to the correct place. make sure that your namespaces matches the namespaces defined in the service. The final message will look like following.


  1. Now click on the Submit Request button as shown in the above image. Nothing will be shown in the output window. :) Don't worry the service doesn't return anything so check the Axis2 console for any output. The Axis2 Console will show the following message if the request was successful.


The "setProduct" service is working fine now lets test the "getProduct" service.

  1. Now select the request of "getProduct" method and add the following SOAP content to the request. (make sure that you have already added the product you are going to query through setProduct method)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.televisionshop">
   <soapenv:Header/>
   <soapenv:Body>
     
         <!--Optional:-->
          <tns:getProduct xmlns:tns="http://myshop.com/xsd">
           <tns:id>001</tns:id>
          </tns:getProduct>
     
   </soapenv:Body>
</soapenv:Envelope>

Now click on Submit request button and the following output will be shown.



You have Successfully tested the web service you created, So in the next post I'll explain you how to write a simple client to access the service we created.

Thank for reading, and please feel free to drop a message or comment below if you have any issues. :)
Subscribe to RSS Feed Follow me on Twitter!