如何在SoapUI testcase中使用Property Transfer工作?

时间:2011-11-22 09:14:10

标签: xpath soapui

我正在尝试使用SoapUI的Transfer Property TestStep将一个WS调用的响应中的值传递给另一个WS调用的请求。

第一次WS响应:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header/>
  <soapenv:Body>
    <ns5:PSResponse xmlns:ns5="http://www.ab.com/abonline/service/PaymentService/1.0/" xmlns:ns6="http://www.ab.com/abonline/service/CustomerCard/1.0/" xmlns:ns7="https://secure.incab.se/DTServerModuleService/v1">
      <ns5:abTransactionReference>1085-0</ns5:abTransactionReference>
      <ns5:status>0</ns5:status>
    </ns5:PSResponse>
  </soapenv:Body>
</soapenv:Envelope>

使用如下表达式解析属性正常:
declare namespace ns5="http://www.ab.com/abnline/service/PaymentService/1.0/" //ns5:abTransactionReference

下一个请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.ab.com/abonline/service/PaymentService/1.0/">
  <soapenv:Header/>
  <soapenv:Body>
    <UpdatePaymentRequest>
      <abTransactionReference>30</abTransactionReference>
... ...

我尝试使用以下方法将属性插入下一个请求:
//abTransactionReference

给我:[Missing match for Target XPath [//abTransactionReference]]

我也尝试了一个完整的xpath:
declare namespace soapenv="http://schemas.xmlsoap.org/soap/envelope/" //soapenv:Envelope/soapenv:Body/UpdatePaymentRequest/abTransactionReference

...导致类似的错误。

2 个答案:

答案 0 :(得分:0)

您不能将""用于命名空间定义。例如,在上面的情况下>&gt;

declare namespace soapenv="http://schemas.xmlsoap.org/soap/envelope/"

应该是

declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';

答案 1 :(得分:0)

尝试将XPath断言添加到UpdatePaymentRequest请求消息。单击XPath Match Configuration对话框中的Declare按钮,您将看到soapUI用于'http://www.ab.com/abonline/service/PaymentService/1.0/'命名空间的前缀。我想会是这样的:

declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns1='http://www.ab.com/abonline/service/PaymentService/1.0/';

(见http://testautomationnoob.blogspot.com.by/2013/12/xpath-in-soapui-part-1-xpath-assertions.html)。然后就不需要XPath断言 - 你可以删除它。因此,在xpath中使用“ns1”前缀。最后,您将拥有以下xpath:

declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns1='http://www.ab.com/abonline/service/PaymentService/1.0/';
/soapenv:Envelope/soapenv:Body/ns1:UpdatePaymentRequest/ns1:abTransactionReference