Saturday, November 17, 2012

Mock a Web Service

Everyone knows that Soap UI is a very useful tool to test web services both SOAP and REST. but Soap UI is a very useful tool for mock a web service as well. Here is the steps to create a mock web service.

Step 1
Create the new Soap UI project. Version of the  Soap UI used is 4.5.1
Select the WSDL file. I have used the schema http://www.webservicex.net/ConvertTemperature.asmx?WSDL
Select the Check boxes - for Create Requests, Create MockService.
Click OK.

Step 2
Select the Operations that we need to mock.
Update the Path which will be the URI for the mocked service.
Update the Port number which will be the port for the mocked service.
Select the check box for Start MockService which will start the mock web service.



Step 3
Specify the name of the mock service to create.

Step 4
The Soap UI project structure will be like as follows.



Step 5
Update the Response payload as required to consume. This is very useful for unit testing the negative scenarios.


Step 6
Double click on the Mock Web service.(eg. ConvertTemperatureSoap MockService)
Click the Start button and start the mock web service.(also we can start like - Right click on the Mock Service project and Start the mock service )


Step 7
Trigger the request aganist the mock web service uri http://localhost:8088//mockConvertTemperatureSoap and we can see the mocked response as the response for the request.


This is how we can mock a web service easily.... Check it out....

Wednesday, November 14, 2012

REST vs SOAP

After long years of developement of SOAP and REST web services thought of recollect what is the difference between SOAP and REST and these came in my mind.......

SOAP - Simple Object Access Protocol

SOAP web services are schema(WSDL, XSD) based web services. Both the requests and responses are in XML format. For enterprise level or distributed applications we can use SOAP web services and its easy to communicate with different end points. Built in error handling techniques and retry logic but SOAP data reads cannot be cached. It support SSL security.

REST - Representational State Transfer

REST web services are not a schema based web services. We can control the request and response format based on the requirement. The most commonly used is JSON format. we can easily send the response as in XML, HTML etc. formats as we required. REST Web services are useful for public exposed web services. The REST reads are cashed. Comparatively faster than SOAP. Support both WS- Security and SSL. And it is easy to write clients and APIs with REST.