Forum Discussion

JKelsey's avatar
JKelsey
Occasional Contributor
15 years ago

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:
<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.
  • Hi!

    hmm.. regarding #1; could it be that the nil=true attribute is actually added by the form-editor while you are editing the document (and leaving the values empty)? If so, try adding an empty property-expansion as the value, for example ${empty}, to workaround this.

    regarding #2, try using the "Transfer child nodes" option for the property transfer and selecting the parent of the element you want to transfer

    Does that help?

    regards!

    /Ole
    eviware.com
  • JKelsey's avatar
    JKelsey
    Occasional Contributor
    Regarding #1 - no, the nil=true is in the actual response. We're going to change our code to not do that anymore, so I think I don't need an answer for that problem anymore.

    Regarding #2 - thank you, that works. It took me a while to figure out that I needed to set a source XPath for the property transfer. But once I did that it worked.

    Thanks again.
  • Hi!

    oh sorry, I thought the nil=true was in the request from soapUI, my bad!

    Glad you got it working!

    regards,

    /Ole
    eviware.com