JKelsey
15 years agoOccasional Contributor
Property transfer to empty XML nodes
I'm trying to use the Response from one test step as the basis for the Request to another. The Response has XML that looks like this:
I'm trying to use a Property Transfer test step to first transfer the Response to the Request for the next test step, then update all the empty fields in the Request. Simple nodes that take a value (like Description) are working fine. I'm having trouble with the nodes that contain nested XML - Vendor and RelatedDocuments. I want the request XML to look like this:
Problem #1:
When I try to transfer values into //Purchase[1]/Vendor[1]/Name[1] and //Purchase[1]/Vendor[1]/Uri[1] the resulting XML looks like this:
I don't want the i:nil="true" part anymore. How can I make that go away?
Problem #2:
Because the RelatedDocuments node is empty in the response XML, I can't use the full XPath for the child nodes in my property transfer. I tried transferring a value to //Purchase[1]/RelatedDocuments[1]/RelatedDocument[1]/Path[1] and got this error:
Missing match for Target XPath [//Purchase[1]/RelatedDocuments[1]/RelatedDocument[1]/Path[1]]
I also tried transferring the full XML block into //Purchase[1]/RelatedDocuments[1]. When I do that, the Request XML looks like this:
How can I add XML nodes to the request that were not present in the response?
Thanks.
<Purchase xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Date>2011-01-21</Date>
<Description/>
<OrderNumber>API-00003</OrderNumber>
<OrderPO/>
<TotalPrice>0.00000</TotalPrice>
<Vendor>
<Name i:nil="true"/>
<Uri i:nil="true"/>
</Vendor>
<Notes/>
<RelatedDocuments/>
<InvoiceNumber/>
</Purchase>
I'm trying to use a Property Transfer test step to first transfer the Response to the Request for the next test step, then update all the empty fields in the Request. Simple nodes that take a value (like Description) are working fine. I'm having trouble with the nodes that contain nested XML - Vendor and RelatedDocuments. I want the request XML to look like this:
<Purchase xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Date>2011-01-21</Date>
<Description/>
<OrderNumber>API-00003</OrderNumber>
<OrderPO/>
<TotalPrice>0.00000</TotalPrice>
<Vendor>
<Name>a new vendor that maps to a manufacturer</Name>
<Uri>http://hostname/WebService/Manufacturer.svc/14</Uri>
</Vendor>
<Notes/>
<RelatedDocuments>
<RelatedDocument>
<Path>serialnumbers.txt</Path>
<Description>serial numbers (in use and available)</Description>
</RelatedDocument>
<RelatedDocument>
<Path>support.txt</Path>
<Description>support contact information</Description>
</RelatedDocument>
</RelatedDocuments>
<InvoiceNumber/>
</Purchase>
Problem #1:
When I try to transfer values into //Purchase[1]/Vendor[1]/Name[1] and //Purchase[1]/Vendor[1]/Uri[1] the resulting XML looks like this:
<Vendor>
<Name i:nil="true">a new vendor that maps to a manufacturer</Name>
<Uri i:nil="true">http://hostname/WebService/Manufacturer.svc/14</Uri>
</Vendor>
I don't want the i:nil="true" part anymore. How can I make that go away?
Problem #2:
Because the RelatedDocuments node is empty in the response XML, I can't use the full XPath for the child nodes in my property transfer. I tried transferring a value to //Purchase[1]/RelatedDocuments[1]/RelatedDocument[1]/Path[1] and got this error:
Missing match for Target XPath [//Purchase[1]/RelatedDocuments[1]/RelatedDocument[1]/Path[1]]
I also tried transferring the full XML block into //Purchase[1]/RelatedDocuments[1]. When I do that, the Request XML looks like this:
<RelatedDocuments><![CDATA[ <RelatedDocument> <Path>serialnumbers.txt</Path> <Description>serial numbers (in use and available)</Description> </RelatedDocument> <RelatedDocument> <Path>support.txt</Path> <Description>support contact information</Description> </RelatedDocument>]]></RelatedDocuments>
How can I add XML nodes to the request that were not present in the response?
Thanks.