2015-03-02 69 views
0

我想设置代币的价值在这个肥皂WS头SOAPUI财产转移到请求头

<soapenv:Enveloppe ... 
<soapenv:Header> 
    <web:token>123456 </web:token> 

名为测试步骤响应得到idSession

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
     <soap:Body> 
      <ns1:authentification xmlns:ns1="http://ws.demowebservices.com/"> 
       <bloc1> 
        <bloc2> 
          <idSession>e1c64cd9-b933-4f56-ae1f-0f7d7f23942b</idSession> 
        </bloc2> 

我试图把在 - 网络之间:令牌标签

${test#Response#//ns1:authentification/bloc1/bloc2/idSession} 

,但它不工作

我应该改为什么?

+1

您是否尝试过的文件? http://www.soapui.org/soap-and-wsdl/headers-and-attachments.html#1-Custom-HTTP-Headers – SiKing 2015-03-02 17:35:09

+0

SiKing建议应该帮助你。你也可以看看它和它http://www.soapui.org/scripting---properties/tips---tricks.html#5-Change-a-request-XML-from-groovy – Rao 2015-03-02 18:39:22

+0

为什么我需要自定义标题还是使用groovy?为什么我可以使用属性传输来设置请求头像我可以使用请求主体一样?我非常喜欢初学者,我希望尽可能简单的解决方案:我真的有义务放弃财产转移? – user310291 2015-03-02 22:05:49

回答

2

我不知道这是否是你想要什么来实现的,但是如果你有一个叫SOAP Test stepTest Request要使用此请求的<soapenv:Header><web:token></soapenv:Header>的另一SOAP Test step值,你可以在参考这个值第二SOAP Test step请求使用后续的语法:

<soapenv:Enveloppe ... 
<soapenv:Header> 
    <web:token>${Test Request#Request#//soapenv:Header/web:token}</web:token> 

语法${Test Request#Request#//soapenv:Header/web:token}有三个部分,所述测试步骤的名称,随后由属性(可能是#Request#Response),最后是xpath来获取值//soapenv:Header/web:token

更新:

至于你说的您将两个SOAP Test Request,第一个被称为test一个有遵循response

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <ns1:authentification xmlns:ns1="http://ws.demowebservices.com/"> 
     <bloc1> 
      <bloc2> 
       <idSession>e1c64cd9-b933-4f56-ae1f-0f7d7f23942b</idSession> 
      </bloc2> 
     </bloc1> 
     </ns1:authentification> 
    </soap:Body> 
</soap:Envelope> 

第二个被命名为例如test 2(唐”因为第二个名字不会影响你的目的),并且具有以下request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soapenv:Header> 
    <web:token>${test#Response#//ns1:authentification/bloc1/bloc2/idSession}</web:token> 
    </soapenv:Header> 
    <soapenv:Body> 
     ... 
    </soapenv:Body> 
</soapenv:Envelope> 

使用${test#Response#//ns1:authentification/bloc1/bloc2/idSession}您正确引用test响应的idSession值。就拿http log标签一看,当你如后续图像中发送您test 2

enter image description here

希望这有助于

+0

谢谢,这正是我需要的,我是等待服务器的家伙后,能够测试它:) – user310291 2015-03-03 14:24:14

+0

@ user310291确定完美的':)',所以终于工作?很高兴帮助你! – albciff 2015-03-03 14:25:10

+0

我有错误:你能看看我更新后的帖子感谢:) – user310291 2015-03-03 16:51:25