I.Overview
1.1SoapuiIntroduction
Because a Web Service is called by a program, it generally does not provide an interface for end users or testers to use directly. Before tools such as soapui appear, testers have to write their own programs to test it, this requires testers to spend a lot of energy on understanding the underlying interfaces, calling relationships, and detailed protocols, so that they cannot concentrate on testing.
Soapui is a simple and practical open-source Web service testing tool. It provides desktop applications and IDE plug-ins.
Soapui calls the Web service through soap (Simple Object Access Protocol)/HTTP (Hypertext Transfer Protocol) to test the functions, load, and compliance of the web service. You can not only test soap-based Web services, but also test rest-based Web Services.
Soapui is developed based on Java and supports multiple platforms. It is open-source and easy to install. Being able to quickly build projects and organize test cases is a major feature of this tool. You can download an installation package from the official soapui website (Windows 3.0.1 is used in this article) and install it directly. The installation package contains the jre1.6 version required by a soapui. After installation, you need to set the java_home variable to point to the corresponding JRE directory, modify the PATH variable, and add the bin directory of jre1.6.
1.2SoapuiVersion description
Soapui has basic and professional versions.
General functions can be implemented without applying for a license.
- Compared with the normal version, you can add more flexible test steps.
- For a professional version, you must apply for a free license. The license is valid for two weeks. The license application is very simple. You only need to click "apply for trial" in the "soapui pro license" dialog box, and then fill in the mailbox, name, and company name, you can receive the license from your mailbox in about one minute. however, a single email address can only apply for one license, that is, after the two-week trial period, you cannot use the license used in the previous application to apply again.
- Commercial non-open-source version
1.3SoapuiWebsite Information
The soapui website information is as follows:
Soapui Official Website: http://www.soapui.org/
Http://sourceforge.net/projects/soapui/files/ for soapui
II.Install
2.1Installation Process
The installation process is very simple and omitted. JDK needs to be configured.
III.Use
3.1 soapuiBasic operations
3.1.1Create a project
1. Start soapui, right-click the project in the left navigation tree, and select new soapui Project (CTRL-N)
2. The new soapui project dialog box is displayed, for example:
Here we take "Chinese TV Program Notice Web Service": http://www.webxml.com.cn/webservices/ChinaTVprogramWebService.asmx? For example, create a WSDL project.
Enter the Project name: chinatv
WSDL: http://www.webxml.com.cn/webservices/ChinaTVprogramWebService.asmx? WSDL
The WSDL can be a URL or a static WSDL file.
Selected by default:
Create sample requests for all operations? (Example of creating a request for each interface)
3. Load
3.1.2Single Service Request
The soapui tool parses the wdsl file to obtain the service interface and create a request ., The service provides eight interfaces and two interfaces are provided according to the soap version.
Click to expand the "gettvstationdataset" SOAP request "request 1 ":
What we see is the service request SOAP message, where "?" The question mark indicates the input parameter. In this example,-1 indicates the request input parameter value "-1". Then, click the icon to obtain the request result,
We can see the returned SOAP message and its data.
3.1.3Save Project
The saved Project is a file in. XML format named after project name +-soapui-project.xml.
Save all projects
To save all projects in the left-side navigation tree of soapui at one time, click "" In the toolbar "".
Save all projects and exit
If you want to save all projects in the left-side navigation tree of soapui at one time and exit soapui, click "file" -- "exit without saving" in the menu ".
Save a single project
To save a single project, right-click the name of the project to be saved and choose Save project from the shortcut menu ". If you want to save it as a project, select Save project ".
Project naming rules: Project name-soapui-project.xml
3.1.4Delete a project
To delete a project, right-click the project name and select Remove"
3.1.5Import Project
If you want to import a project that has been saved but deleted from the project navigation bar of soapui. Select "file"-"Import Porject" from the menu ".
3.2SoapuiOfTestsuiteFunction
3.2.1Build Test Cases
Right-click the project chinatv and choose new testsuite to build a test suite, for example:
Then, right-click "request 1" in the gettvstationdatsset request and select "add to testcase" to create a new testcase and add the service request to testcase:
In this way, we have the first test case:
Because the input parameters of the service request have been set in the above process, we can double-click testcase1 to directly run it,
We see the green bar, which indicates that the Operation passes.
3.2.2Add a checkpoint
, Open the service request gettvstationdataset--request 1, click to add the checkpoint:
There are multiple types of checkpoints. Here we select "ins" and enter the checkpoint "CCTV ":
We run the service request gettvstationdataset-request 1,
The checkpoint is valid: contains-valid.
3.2.3Organize test steps
Set getareadataset (list of supported provinces, cities, regions, and classified TVs ),
Gettvstationdataset (obtain the TV station list by province/city ID or classification TV ID ),
Gettvchanneldataset (obtain the TV station channel list through the TV station ID ),
Gettvprogramdataset (obtain the program list of this channel by channel ID) is added to the test step of testcase1 in turn, and then the test step is organized to get the program list of the CCTV-1.
Test procedure:
- Obtain the category ID of "Central TV"-1"
- Obtain the "CCTV" ID in the "Central Television" category: "39"
- Get the channel "CCTV-1" ID for CCTV: "606"
- Gets the list of programs that are frequently "CCTV-1"
We need to request the serviceGetareadatasetThe "Central TV" ID "-1" in the result serves as a service requestGettvstationdatasetInput parameter, right-clickGetareadataset-request 1, SelectInsert step-property transfer,
This property transfer is used for interaction between two service requests. we name it "areatransferstation"
SelectGetareadataset-request 1OfResponseIn target, we selectGettvstationdataset-request 1OfRequestAnd select the node (arealist [4]) in the soap message returned by the getareadataset service request through the script (areaid [1]). the value is passed to the service request gettvstationdataset as the value of the input parameter (theareaid [1.
From:
In the same operation procedure, we organized the interaction between several other service requests, and completed a complete test step. Finally, we ran testcase and saw all the running results:
Note:
Areatransferstation
Declare namespace diffgr = "urn: Schemas-Microsoft-com: xml-diffgram-v1 ";
// Diffgr: DiffGram/area/arealist [4]/areaid [1]
Declare namespace web = "http://WebXml.com.cn /";
// Web: gettvstationdataset/Web: theareaid [1]
Stationtransferchannel
Declare namespace diffgr = "urn: Schemas-Microsoft-com: xml-diffgram-v1 ";
// Diffgr: DiffGram/station/TVstation [1]/tvstationid [1]
Declare namespace web = "http://WebXml.com.cn /";
// Web: gettvchanneldataset/Web: thetvstationid [1]
Channeltransferprogram
Declare namespace diffgr = "urn: Schemas-Microsoft-com: xml-diffgram-v1 ";
// Diffgr: DiffGram/channe/tvchanne [1]/tvchannelid [1]
Declare namespace web = "http://WebXml.com.cn /";
// Web: gettvprogramdateset/Web: thetvchannelid [1], Web: thedate [1]
3.3SoapuiSimulation Server
When the soapui simulates the server, it is called by other interfaces and can provide the required results for the interfaces that call it.
The sopaui simulation server is mainly a mockservice function. Therefore, to simulate a server, you must select "create mockservice" in the "New soapui project" dialog box when creating a project ".
3.4SoapuiSimulate a client
Soapui simulates the client, that is, as the soapui as the message sender, sends the request message to the address in the address bar and receives the response.
The soapui simulation client mainly provides the "request" function. Therefore, when creating a project, you must select the "Create requests" option in the "New soapui project" dialog box.
4.Other functions
4.1 Web ServicePerformance Testing
Soapui can perform load tests through test cases in the test suite to check web service performance.
1. Right-click the test case to perform the performance test, for example, test case1 ",
2. Select "New loadtest" in the shortcut menu, as shown in the red box. System display dialog box:
3. enter the name of the Load Test in "New loadtest. You can also retain the default value.
4. Click OK ". The server Load balancer test page is displayed on the right, for example:
As shown in the following figure:
Threads: number of concurrent threads
Strategy: concurrency policy. Select "simple"
Test delay: latency between requests.
Limit: the running time limit.
5. To enable the soapui to calculate the number of successful requests and the number of failed requests, you need to add assertions to the load test. Such as adding checkpoints and not soap fault.
6. Click "" In the toolbar of the "loadtest" interface to set parameters for the load test. For example:
7. Click "" In the toolbar to run the load test.
Running result. The following parameters must be noted:
L CNT: Total number of requests sent
L TPS: Number of requests per second
L err: Number of error requests
4.2Set the packet capture tool
Install the tcpmon tool locally before setting the packet capture tool tcpmon on soapui.
Tcpmon is equivalent to a transfer station. It can set the receiving port and the target port;
Function: intercept the HTTP request and HTTP response information between the customer and the service, and view the information. tcpmon is a project in Apache: http://ws.apache.org/commons/tcpmon/download.cgi.
1. Select "file"-preferences. The following page is displayed:
2. Select "Tools" in the navigation tree. The "Tools" project setting parameters are displayed on the right side of the page.
3. Click "Browser" next to "Apache tcpmon" on the right and select the installation directory of the installed tcpmon tool.
4. Click OK.
5. Select "Tools"-"launch tcpmon" to start the packet capture tool.
4.3Introduction to packet capture tools
Packet capture process:
The tcpmon tool plays the role of a proxy in packet capture as follows:
L The message sender first sends the request message to tcpmon
L tcpmon receives the request message and forwards it to the target host.
L after receiving the request message, the target host returns the Response Message to tcpmon.
L after receiving the response message, tcpmon forwards the response to the sender's host.
1. Select "Tools"-"launch tcpmon" in the menu bar, for example:
2. Set the listening port and the IP address and port number of the target host.
3. Click "add ".
Generally, if the client wants to request web services, it must set the port number to 9876. However, if tcpmon is available, the client can set the port number to 8080. in this way, tcpmon can listen to port 8080, display the HTTP request on the interface after receiving it, then send the request to port 9876, and listen again to the HTTP Response sent back from Port 9876, and displayed on the interface;
4. To stop packet capture, click STOP ".
5.Available WebService addresses
1. CCTV program WebService
Http://www.webxml.com.cn/webservices/ChinaTVprogramWebService.asmx? WSDL
2. Weather Forecast WebService
Http://www.webservicex.net/WeatherForecast.asmx? WSDL
3. query the WebService of the mobile phone's home location
Http://fy.webxml.com.cn/webservices/EnglishChinese.asmx? WSDL