Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Loadrunner Test webservice II: pass soap_reuest

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

After I had written half of the article before, after saving the draft, I finally found that it was gone, so I had to write it all over again. This time, I would not be so verbose, mainly sharing the steps of the test.

There are three ways for LoadRunner to test webservice: 1, through the web_service_call function, that is, to import the wsdl file or URL; 2, through the soap_request function, by importing the xml file to achieve; 3, through the http protocol to handwrite scripts.

The first can be accessed: http://gungun.blog.51cto.com/9585287/1591100

Today's focus is on the second, which imports the xml file through Import SOAP to implement the call to the webservice interface.

Let's take the well-known weather forecast as an example:

URL: http://webservice.webxml.com.cn/webservices/weatherwebservice.asmx for Weather Forecast

Call the getWeatherbyCityName method.

Open the http://webservice.webxml.com.cn/webservices/weatherwebservice.asmx?op=getWeatherbyCityName page, as shown in the following figure:

Save the portion of the red box below to the xml file and import the XML file you just had, as shown in the following figure:

The following code is automatically generated after import:

Soap_request ("StepName=SOAP Request"

"URL= http://webservice.webxml.com.cn/webservices/weatherwebservice.asmx",

"SOAPEnvelope="

"

"

"

"string" / / fill in the name of the city here

"

"

"

"SOAPAction=getWeatherbyCityName"

"ResponseParam=response"

"Snapshot=t1418827945.inf"

LAST)

Then add the header information before the code you just generated. The content that needs to be added is shown in the first figure, where "Content-Length" does not need to be added.

The additional code to be added in this example is as follows:

Web_add_header ("POST"

"/ WebServices/WeatherWebService.asmx HTTP/1.1")

Web_add_header ("Host"

"webservice.webxml.com.cn")

Web_add_header ("Content-Type"

"application/soap+xml; charset=utf-8") / / the note here is different from the screenshot.

Web_add_header ("SOAPAction"

"\" http://WebXml.com.cn/getWeatherbyCityName\"");

This is done simply by testing Webservice through the soap_request function.

After fetching the XML data returned by WebService, you can use XPath to validate the data. LR provides several functions to handle XML:

Lr_xml_get_values () / / Retrieves values of XML elements found by a query

Lr_xml_set_values () / / Sets the values of XML elements found by a query

Lr_xml_extract () / / Extracts XML string fragments from an XML string

Lr_xml_delete () / / Deletes fragments from an XML string

Lr_xml_replace () / / Replaces fragments of an XML string

Lr_xml_insert () / / Inserts a new XML fragment into an XML string

Lr_xml_find () / / Verifies that XML values are returned by a query

Lr_xml_transform () / / Applies Extensible Stylesheet Language (XSL) Transformation to XML data

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report