Forum Discussion

rickfish's avatar
rickfish
New Contributor
12 years ago

Cannot get property transfer to work

I cannot for the life of me get property transfer to work. I don't understand the syntax of how to describe what I want transferred - the help does not help me as there are very few examples.

let's say I have two requests and I want to move the result from the first request to the second request:

Request 1:
The request:
<anyrequest>
<action>GetName</action>
</anyrequest>

The response:
<anyresponse>
<theresponse>Rick</theresponse>
</anyresponse>

Request 2:
<anotherrequest>
<name></name>
</anotherrequest>

what EXACTLY do I put in the property transfer dialog to move 'Rick' into 'name'?

Is there a simple example that shows this? I have seen all the examples and cannot glean the solution.
Is there a sample project I can download that shows this?

5 Replies

  • Although soapui does have a property transfer form that you can fill out, I prefer to do this in groovy, as I'm usually dooing things with the properties as well as transfering them, and groovy is best for that sort of thing. Anyways, here's how I would do it.

    Create a custom property called name at either the test step/case/suite level (depending on the scope of this property). Here, I put the property in at the test suite level. Next in the response, put ${#TestSuite#name} between the name tags.

    Then, create a groovy script, and drop this code in.

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
    def holder = groovyUtils.getXmlHolder( "YourRequestNameGoesHere#ResponseAsXml" );

    def name = holder.getNodeValue(" //Response[1]/action[1]/name[1]/text()")

    testRunner.testCase.testSuite.setPropertyValue("name",name)



    That should be enough to do it. You just need to have the xpath (//Response[1]/action[1]/name[1]/text()) right, as it varies by response.
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Or you can just put a property expansion directly in the second request step and forget extra properties or property transfers. Assuming your first request is called 'Request 1':

    <anotherrequest>
    <name>${Request 1#Response#//anyresponse[1]/theresponse[1]}</name>
    </anotherrequest>
  • rickfish's avatar
    rickfish
    New Contributor
    Thanks but it isn't working for me...I must be doing something wrong. I'll post the actual xml that I am using. Keep in mind this is just a silly testcase

    Step 1 request named 'ConversionRate':
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
    <soapenv:Header/>
    <soapenv:Body>
    <web:ConversionRate>
    <web:FromCurrency>AWG</web:FromCurrency>
    <web:ToCurrency>AUD</web:ToCurrency>
    </web:ConversionRate>
    </soapenv:Body>
    </soapenv:Envelope>

    Step 1 response:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <ConversionRateResponse xmlns="http://www.webserviceX.NET/">
    <ConversionRateResult>0.5444</ConversionRateResult>
    </ConversionRateResponse>
    </soap:Body>
    </soap:Envelope>

    Step 2 request:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
    <soapenv:Header/>
    <soapenv:Body>
    <web:ConversionRate>
    <web:FromCurrency>${ConversionRate#Response#//ConversionRateResponse[1]/ConversionRateResult[1]}</web:FromCurrency>
    <web:ToCurrency>?</web:ToCurrency>
    </web:ConversionRate>
    </soapenv:Body>
    </soapenv:Envelope>

    Note that the request that is generated has nothing between begin and end tags of <web:FromCurrency>. I would expect to see 0.5444. This request would ultimately fail... I am just trying to see if I can get the property expansion to work...
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    <web:FromCurrency>${ConversionRate#Request#declare namespace ns1='http://www.webserviceX.NET/'; //ns1:ConversionRateResponse[1]/ns1:ConversionRateResult[1]}</web:FromCurrency>
  • rickfish's avatar
    rickfish
    New Contributor
    Thanks! That worked - had to change #Request to #Response but after that it worked. I appreciate it...