Forum Discussion

akacodemonkey's avatar
akacodemonkey
New Contributor
12 years ago

[Resolved] property expansion on soap message

hello, I'm looking for some help with using information received on one test step to be used in the next step. The response from step 1 is as follows:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<ActivityId CorrelationId="d5237c79-9a11-40e3-b38d-0e9556c6314f" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">d24565d2-2d85-4972-80ee-acd985969680</ActivityId>
</s:Header>
<s:Body>
<GetCustomersResponse xmlns="http://tempuri.org/">
<GetCustomersResult xmlns:a="http://schemas.datacontract.org/2004/07/Iress.MSO.DIP.Application.Contracts.Intemediary.Customer" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:CustomerDetails>
<a:Customers>
<a:CustomerDto>
<a:DateOfBirth>1983-08-06T01:00:00</a:DateOfBirth>
<a:Gender>2</a:Gender>
<a:HasChangedNameInLastThreeYears>false</a:HasChangedNameInLastThreeYears>
<a:HasFinancialDependants>false</a:HasFinancialDependants>
<a:Id>0407029a-818d-e311-a507-984be1759724</a:Id>
<a:IsPermanentUkResident>true</a:IsPermanentUkResident>
<a:Name>
<a:Forename>Brian</a:Forename>
<a:MiddleName/>
<a:Surname>Curlew</a:Surname>
<a:Title>1</a:Title>
</a:Name>
<a:Nationality>1</a:Nationality>
<a:PreviousName i:nil="true"/>
</a:CustomerDto>
</a:Customers>
<a:Dependants/>
</a:CustomerDetails>
<b:CustomerOccupancyDto>
<b:CurrentOccupancy>
<b:Address>
<b:County>GLOUCESTERSHIRE</b:County>
<b:District/>
<b:Flat/>
<b:HouseName i:nil="true"/>
<b:HouseNumber>1</b:HouseNumber>
<b:Postcode>GL4 4WB</b:Postcode>
<b:Street>High Street</b:Street>
<b:Town>CHELTENHAM</b:Town>
</b:Address>
<b:AddressTargeted>false</b:AddressTargeted>
<b:Hash i:nil="true"/>
<b:Id i:nil="true"/>
<b:IsDeleted>false</b:IsDeleted>
<b:IsLettingAgent i:nil="true"/>
<b:OccupancyStatus>5</b:OccupancyStatus>
<b:TimeAtAddressInMonths>0</b:TimeAtAddressInMonths>
<b:TimeAtAddressInYears>3</b:TimeAtAddressInYears>
</b:CurrentOccupancy>
<b:CustomerId>0407029a-818d-e311-a507-984be1759724</b:CustomerId>
<b:PreviousOccupancies/>
</b:CustomerOccupancyDto>
</a:CustomersOccupancy>
</GetCustomersResult>
</GetCustomersResponse>
</s:Body>
</s:Envelope>

I've used the property expansion syntax

${#GetCustomerDetails#Response#//s:Envelope/s:Body/GetCustomersResponse/GetCustomersResult/a:CustomerDetails/a:Customers[1]/a:CustomerDto/a:DateOfBirth/text()}

that didnt work so I then used a property transfer to move the response into a property (which worked) and then placed the following command

${#TestCase#CustomerDetails#[//s:Envelope/s:Body/GetCustomersResponse/GetCustomersResult/a:CustomerDetails/a:Customers[1]/a:CustomerDto/a:DateOfBirth/text()]}

again didnt work. I've checked the xpath and it is valid and returns the data I expect.

Any ideas? I'd be grateful for the help

5 Replies

  • followed that through with no luck. I'm assuming that somehow the xpath is not being evaluated correctly, although it works fine when tested outside SOAPUI. The property is being populated correctly, its the assignment in the request that is failing. If I remove the xpath from the command it will dump out the entire message into the request.
    e.g.

    ${#TestCase#CustomerDetails} - will insert the contents of the response in the request

    ${#TestCase#CustomerDetails#//s:Envelope/s:Body/GetCustomersResponse/GetCustomersResult/a:CustomerDetails/a:Customers[1]/a:CustomerDto/a:DateOfBirth/text()} returns nothing.
  • nmrao's avatar
    nmrao
    Icon for Champion Level 1 rankChampion Level 1
    Can you show the xml snippet of 2nd request where value from first response is required/replaced? Assuming that you need DateOfBirth from first request.
  • Cracked it in the end. The problem was (as I suspected) with the XPAth. One of the nodes (<GetCustomersResponse xmlns="http://tempuri.org/">) is assigned a namespace but no alias. so although the xpath I created worked in a number of other applications it failed here. I changed the query to 'step' over this node and it worked a treated.

    Thanks for the help.