Labels

Java (10) Spring (10) Spring MVC (6) Web Services (5) Rest (4) Javascript (3) Nodejs (3) Spring Batch (3) Angular (2) Angular2 (2) Angular6 (2) Expressjs (2) Passportjs (2) SOAP (2) SOAPUI (2) Spring Boot (2) AJAX (1) H2 (1) JQuery (1) JUnit (1) Npm (1) Puppeteer (1) Python (1) RaspberryPi (1) Raspbian (1) SQL (1) SQLite (1) Scripts (1) html (1)

Saturday, May 27, 2017

SoapUI mock web services tricks

In a previous article I explained how to create and deploy a mock web service using SOAPUI.

In the process of testing applications sometimes you need to do quick changes in a mock web service and deploy it shiftly.

XML project file in SoapUI

When you export a SoapUI project you will get an xml that contains all the information and configuration of your project. Furthermore, if your project contains a mock service with its responses, those will be inside that xml.

For instance I have created this simple project


I have added three very simple responses:



You can save it with Project --> Save project as




 Then, if you open that xml flile, you will see that at the end of it are the responses that I created above.


So If you change the data in those responses and import the project again you will see that the responses have changed accordingly.

This is a method that I found out for doing quick small changes across several SoapUI projects that I use frequently. 

Nevertheless I still have not figured out how tho add responses using only this xml file. I do not fully understand the headings of the responses.


Deploying a SoapUI mock web service as a war file using the command line.


So if you have saved your soapui project into a xml as we did above, you can create a .war from it using the command line. I have troubles finding information about this and I think it is a great trick.

This is the .bat file that I use:



set war_file=D:\hugo_documentos\mock2.war
set war_dir=D:\hugo_documentos
set xml_dir=D:\hugo_documentos\mock-example-soapui-project.xml
set soapui-settings=C:\Users\hugo\soapui-settings.xml

cd /d C:\Program Files (x86)\SmartBear\SoapUI-5.3.0\bin

wargenerator.bat -f %war_file% -d %war_dir% -w true -x true -s %soapui-settings% %xml_dir%

pause

The trick is to use an executable called wargenerator that you will find inside the bin folder of your SoapUI installation folder. You will have to give it as inputs the place where you want the war file, the war directory, the SoapUI settings xml and the xml of your project.

I hope this helps!




1 comment: