Skip to content

Mock Server With SoapUI#

What Is The SoapUI?#

  • SoapUI is a tool for testing Web Services; these can be the SOAP Web Services as well RESTful Web Services or HTTP based services. SoapUI is an Open Source and completely free tool with a commercial companion -ReadyAPI- that has extra functionality for companies with mission critical Web Services.
  • More information

Mock Web Services By SoapUI#

  • As a developer, there are some cases you have to implement a feature for calling Web Services and when you finish your implementation then you would need to test your implementation on local and to do it you also need a mock Web Services on your local. So The SoapUI will help you to create a mock Web Services easily.

Prepare Data#

  • To create a mock Web Services on SoapUI, you need to have a WDSL file.
  • In this example I will choose country list SOAP service because it is the one that is working well.
  • So you need go to country list SOAP service by your browser. Then Right Click and choose Save As. After that you save the file with type .wsdl at any folder that you want.

 #zoom

SoapUI Configuration#

  • If you don't know to install SoapUI on your computer (especially Linux computer) so you can view this post for installation.
  • Now, let's open SoapUI then go to File --> New Soap UI Project.
  • Then follow steps as in the image below:
    • Put a name of the Soap project.
    • Click Browse button to choose the wsdl file.
    • Find and choose wsdl file.
    • Click Open button.

 #zoom

  • Now, let's make sure you check the first box as in the image and click Ok.

 #zoom

  • After that you will see there are two generated soap api request suits.

 #zoom

  • In which the first generated soap api request suit CountryInfoServiceSoapBinding is used for SOAP version 1.1. The second generated soap api request suilt CountryInfoServiceSoapBinding12 is used for SOAP version 1.2.
  • You can try to open an generated soap api request, put a value and try to call it. It will call to the real Web Service and return the response like you use the postman to call.

 #zoom

  • Now, to generate SOAP mock server, you can Right Click on the CountryInfoServiceSoapBinding suit and choose Generate Soap Mock Service.

 #zoom

  • Then you need to put a path name and the port for your soap mock server and click ok.

 #zoom

  • Now, you will see the generated mock service has been created, then you can go to the api that you want to call and edit the mock response value.

 #zoom

  • Finally, click the button start to start your mock soap server.

 #zoom

Testing#

  • Now, you can go to soap api request suit CountryInfoServiceSoapBinding and change the server url as in the image which point to your mock server and execute the request for testing. You should receive the successful result as in the image below.

 #zoom

 #zoom

See Also#

References#