Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

WebService Test of LR based on HTTP Protocol

Shulou Source: shulou.com Published: 2022-06-03 05:57:09 11月24日 Update

It has recently been found that things that have been done before will soon be forgotten without a firm grasp, so use these things to retain some test methods so that you can review them later.

The last test method of WebService is to write a script by hand to complete the test through the HTTP protocol. Although the script is handwritten here, most of the work is still done by copy and paste. It is very simple, and the following is a brief record.

In this way, like soap_request, it is a request to find the interface document and use these requests to write functions.

First, LR creates a script for the HTTP protocol.

Second, the script uses web_custom_request (); function, where the parameter url is the address of our weather forecast: http://webservice.webxml.com.cn/WebServices/WeatherWebService.asmx

Our request is in Method=POST,Body. The final code is as follows:

Web_custom_request ("web_custom_request"

"URL= http://webservice.webxml.com.cn/WebServices/WeatherWebService.asmx",

"Method=POST"

"TargetFrame="

"Resource=0"

"Referer="

"Body= Shanghai"

LAST)

This completes our web_custom_request () function

When we return the visit, there will be an error in the script:

Action.c (17): Error-26616: HTTP Status-Code=415 (Unsupported Media Type) for

"http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx" [MsgId: MERR-26616]

The reason for this error is that the packet we sent does not have a clear format type, and the server has an error when verifying the format, so we need to manually add a Header header and use the function web_add_header () to add web_add_header ("Content-Type").

"application/soap+xml; charset=utf-8")

So that you can run it again and you can succeed.

Careful students may find that in Shanghai

This is clearly the place to fill in the city, why is it filled in a pile of garbled codes?

This is because the format we send is in utf-8 format, so it also needs to be utf-8 encoded when sending city names, otherwise the server cannot recognize it. As for the conversion of utf-8 coding, you can search for utf-8 code conversion through Baidu.

This is the last way for LR to test webservice, and so far three have been done.

Tags: Scripts tests functions formats utf-8 methods codes errors things cities methods servers services solid careful successful useful that is garbled code Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Huawei Apple MySQL Linux