2015-03-02 65 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