0
votes

I want to set the value of token in this soap ws header

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

FROM step named test get idSession in 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>

I tried to put in-between web:token tag

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

but it does not work

What should I put instead ?

1
Have you tried documentation? soapui.org/soap-and-wsdl/… - SiKing
What SiKing suggested should help you. You may also take a look at this along with it soapui.org/scripting---properties/… - Rao
Why would I need custom header or use groovy ? Why can I set request header with property transfer like I can do with request body ? I'm very beginner I want as simple solution as possible : so am I really obliged to give up property transfer ? - user310291
@user310291 what do you trying to do exactly? Put a value in <web:token> from another SOAP request or reponse? - albciff
@albciff yes exactly. I can do it when it's in request body, I don't understand why the same syntax does not work in reqjest header. - user310291

1 Answers

2
votes

I'm not sure if this is what you're trying to achieve, however If you have a SOAP Test step called Test Request and you want to use the value of the <soapenv:Header><web:token></soapenv:Header> of this request in another SOAP Test step you can refer this value in the second SOAP Test step request using the follow syntax:

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

The syntax ${Test Request#Request#//soapenv:Header/web:token} has three parts, the name of the test step, followed by the property (could be #Request or #Response), and finally the xpath to get the value //soapenv:Header/web:token.

UPDATED:

As you said you've two SOAP Test Request, the first one is called test an has the follow 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>

The second is named for example test 2 (don't care because the second name not affect your purpose) and has the follow 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>

With ${test#Response#//ns1:authentification/bloc1/bloc2/idSession} you're referencing the idSession value of the test response correctly. Take a look on the http log tab when you send your test 2 as shown in the follow image:

enter image description here

Hope this helps,