我必须测试一些以XML格式响应的web服务,并且我想解析从第一个请求到第二个请求调用的响应.
例如:我提出第一个请求
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.com">
<soapenv:Header/>
<soapenv:Body>
<ser:exec>
<!--Optional:-->
<ser:sName>55</ser:sName>
<!--Zero or more repetitions:-->
<ser:sArguments>{{Param1}}</ser:sArguments>
<ser:sArguments>XX</ser:sArguments>
<ser:sArguments>POSTMAN</ser:sArguments>
<ser:sArguments></ser:sArguments>
</ser:exec>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
谁回应:
<soap:Body>
<ns2:execResponse xmlns:ns4="http://address.com" xmlns:ns3="http://services" xmlns:ns2="http://services.com">
<ns2:execReturn>6666
</ns2:execReturn>
</ns2:execResponse>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
我想将6666放在GlobalVariable或EnvironmentVariable中以用于第二次请求调用.
我现在尝试直到:
首先我在Manage Environments - GLOBALS中设置一个参数(NumberReq),然后在TESTS中我把这段代码:
var jsonData = xml2Json(responseBody);
postman.setEnvironmentVariable("NumberReq", jsonData.execReturn);
Run Code Online (Sandbox Code Playgroud)
在下一个请求中,我尝试使用这样的NumberReq参数:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.com">
<soapenv:Header/>
<soapenv:Body>
<ser:exec>
<!--Optional:-->
<ser:sName>99</ser:sName>
<!--Zero or more repetitions:-->
<ser:sArguments>00</ser:sArguments>
<ser:sArguments>{{NumberReq}}</ser:sArguments>
<ser:sArguments>{{Param2}}</ser:sArguments>
<ser:sArguments>{{Param3}}</ser:sArguments>
</ser:exec>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
我有这两个webservices的集合,我从Postman Runner运行,但不能解析响应.
谁能帮我?谢谢!:)
我需要自动化一些网络服务,我为此创建了一些方法,并且我想使用 Cucumber 来实现这一点,但我不知道如何在下一步中使用返回值。
所以,我有这个功能:
Feature: Create Client and place order
Scenario: Syntax
Given I create client type: "66"
And I create for client: "OUTPUTVALUEfromGiven" an account type "123"
And I create for client: "OUTPUTVALUEfromGiven" an account type "321"
And I want to place order for: "outputvalueFromAnd1"
Run Code Online (Sandbox Code Playgroud)
我有这个步骤:
public class CreateClientSteps {
@Given("^I create client type: \"([^\"]*)\"$")
public static String iCreateClient(String clientType) {
String clientID = "";
System.out.println(clientType);
try {
clientID = util.createClient(clientType);
} catch (IOException e) {
e.printStackTrace();
}
return …Run Code Online (Sandbox Code Playgroud)