When developing web services, you work in two main areas: write the server part or / and client code. In any case, you need both parts of the application for testing. Many developers write test clients / server manually, which is not the optimal solution. The same goals can be accomplished with the popular soapUI package. SoapUI can work both as a test client and as a test service - based on the wsdl provided to it.
Let's try to implement an interesting example: take wsdl from any Internet web service, run two copies of soapUI, configure one as a client and the other as a server. This example will show the highlights of working with soapUI.
Choose any web service available on the Internet. For this example, I asked google search: 'get weather wsdl' and got the url:
www.webservicex.net/WeatherForecast.asmx?WSDLSave it as sample.wsdl, at the same time make sure that the service is live (the above specified worker is July 2009)
')
Let's start with the client emulation.
Run soauUI and create a new client. Name the project client and select the previously saved wsdl. Leave the rest of the default settings.
After creating a client in the project tree, you will see all operations from the service, in particular GetWeatherByZipCode. Click on the operation twice to see the request body, and open this request (Request1).
As you can see, soapUI created a query template with a question mark instead of data. Also pay attention to the toolbar window - there is the path to the service in the Internet. In the request body specify the real ZIP - for example 07203; and start the operation with a green arrow ... In a second you will receive a response from the server, and soapUI will show the response body in the right tab.
Now you can work with a remote server directly, but we are interested in working with mock service and we need to create it ...
Open another copy of soapUI. Create the same project, only with the name Server. To create a service, right-click on the operations tree (WeatherForecastSoap in this example) and select - Generate Mock Service.
In the window that opens, you can specify the port that the service will listen to; Path and operations - leave all the default values and save the settings.
In the project tree, you will see a service branch with supported operations. Click on GetWeatherByZipCode to see its content. Since we are doing the service, then, unlike the client, we will see Response1 - this data goes to the client upon request. As for Request1, the data itself is replaced with a question queue. Try replacing them with valid values. Now start the service and soapUI will start listening to requests.
Go back to the soapUI window with the client. Request1 is still open. Click on the URL in the toolbar window and add a new address:
localhost : 8088 / mockWeatherForecastSoap - you may need to change the port or path.
After adding the address, start the client. As a response, you will see your data that you entered in Response1.
As a result, you have server and client parts based on a single wsdl, and you can test operations. In real life, the example is of no interest, since the client or server must be real systems. But this is an example of a good start for studying soapUI and automated testing of web services.
:
romanenco.com/soapui