Introduction to the WEB Service Unit Test tool example Soapui

Source: Internet
Author: User
Tags soap valid web services soapui wsdl

SoapUI is a simple and practical open source Web Service testing tool that provides both desktop applications and IDE plug-in programs. The ability to quickly build projects and organize test cases is a major feature of the tool, and the following examples show if you use SOAPUI for Web Service unit testing.

L Build Projects

The project in the SoapUI tool is made up of one or more Web services, where we use the Chinese TV trailer Web service:

HTTP://WWW.WEBXML.COM.CN/WEBSERVICES/CHINATVPROGRAMWEBSERVICE.ASMX?WSDL "For example, create a new WSDL project. Click File è New wsdl project , Enter the project name "CHINATV", initial WSDL "

Http://www.webxml.com.cn/webservices/ChinaTVprogramWebService.asmx?wsdl ", as shown in Figure 1:

Where WSDL can be either a URL or a static file of WSDL.

L operation of a single service request

The SoapUI tool parses the WSDL file to get the service interface and creates the request. As shown in Figure 2, 3: The service provides 8 interfaces and provides two different versions depending on the version of SOAP.

Expand the SOAP request "request1 " of the Interface "gettvstationdataset ":

Double-click to view the requested SOAP message: Figure 4

What we see is the service Request SOAP message, where the "? "The question mark represents the entry, modify it to request the parameter value"-1 "(In this instance, 1 for the Central TV), and then click the icon button to run, get the request result: Figure 5

We see the SOAP message returned and the data in it.

L Build Test Cases

Select Project "CHINATV" and right-click, choose New TestSuite , build a test suite as shown in Figure 6

Then, right-click in Testsuite, select New TestCase , create a new TestCase and add the service request to the TestCase: Figure 7

In this way, we have the first test case: Figure 8

Because the service request entry is already set up in the procedure above, we double click TestCase 1 Click to run directly: Figure 9

We see the "Green bar", which means running through.

L Increase the checkpoint.

As pictured, open the service request gettvstationdataset–request 1 , click, add checkpoint: Figure 10

There are several types of checkpoints, where we choose to include "Contains " and enter the check "CCTV": Figure 11

We run the service request gettvstationdataset–request 1 : Figure 12

You can see that the checkpoint is valid:contains-valid .

L organize test steps

Getareadataset (List of supported provinces, cities and categories), Gettvstationdataset (get a list of stations by city or city ID or classified TV ID), Gettvchanneldataset (via TV station ID Get the channel list), Gettvprogramdataset (Get the Channel program list by Channel ID), add to the test step of TestCase 1, then organize the test steps to get a list of "CCTV-1" programs.

Test steps:

1. Get "Central TV" category ID "1"

2. Get "CCTV" ID in "Central TV" Category: "39"

3, access to "CCTV" channel "CCTV-1" ID: "606"

4, get the "CCTV-1" Channel program list as shown in Figure 13

We need to Getareadataset the "Central TV" ID "1" in the result of the service request as a service request Gettvstationdataset , right-click Getareadataset-request 1 , select Insert Step è property Transfer , as shown in Figure 14:

This property Transfer is used for interaction between two service requests, and we name it: "Areatransferstation" as shown in Figure 15

Source we choose getareadataset-request 1 response, Target we choose gettvstationdataset-request 1 Request, The service request is passed to the service request Getareadataset The value of the node (Arealist[4]) in the returned result SOAP message (areaid[1]) through a script selection Gettvstationdataset As the value of the entry parameter (Theareaid[1]).

Including: Declare namespace diffgr=

"Urn:schemas-microsoft-com:xml-diffgram-v1"; Used to declare a namespace that corresponds to a namespace in a SOAP message. As shown in Figure 16

The same procedure, we organize a few other service requests between the interaction, the organization completed a complete test steps, finally we run testcase, see the full results: (green means running through) as shown in Figure 17

Note: SOAPUI official website http://www.soapui.org/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.