问题
When using the Property Transfert
window to transfert a XML node (with children nodes) taken from the response of a first Soap request to a second Soap request, and that both requests are in the same TestCase, it works great :
TestCase 1 :
Source : [First Soap Request] Property : [Response]
declare namespace ns='http://xxx.com';
//ns:xxxxx[1]/ns:return[1]
-------------------------------------------
Target : [Second Soap Request] Property : [Request]
declare namespace ser='http://xxx.com';
//ser:xxxxx[1]/ser:someobject[1]
But if the two requests are in different TestCases, I guess it is required to save the XML node to a TestSuite property first, and then transfert this property to the new Soap request :
TestCase 1 :
Source : [First Soap Request] Property : [Response]
declare namespace ns='http://xxx.com';
//ns:xxxxx[1]/ns:return[1]
-------------------------------------------
Target : [TestSuite1] Property : [myVariableToTransfert]
TestCase 2 :
Source : [TestSuite1] Property : [myVariableToTransfert]
-------------------------------------------
Target : [Second Soap Request] Property : [Request]
declare namespace ser='http://xxx.com';
//ser:xxxxx[1]/ser:someobject[1]
This doesn't work!
It seems I'm unable to get valid XML in the second request when it is taken from the TestSuite as a property. Sometimes the value is null, sometimes it is wrapped in CDATA tags or the XML is entitized ("<" are "<", for example). I'm unable to get the value as real XML, like when both requests are in the same TestCase!
I played with the "Transfert Text Content", "Entitize tranfererred value(s)" and "Transfert Child Nodes" options but without success!
How can I tranfert a XML node from a request in a TestCase to a request in a second TestCase?
回答1:
Set your response value as custom property at test suite and then you can use this for further testing..remember it will save your value as string data so if you are saving your integer data then you have to covert it into integer before further use.Like testRunner.testCase.testSuite.getPropertyValue("").toInteger()
回答2:
Here is the detailed explanation:
Create test suite 1 and the below steps
test case 1
DataGen step
test case 2
Within the DataGen step, open the editor, add new property via clicking on "+" button and select script as Type (you should also give a name to the property now assume the name is yourprop).
At the below side of the screen you should see the script editor. And create a script as below (please notie that you should change the variables according to your web service and XML)
def testXML = context.expand( '${Test Request#Response#declare namespace ns1=\'http://namespace/'; //ns1:WebServiceNameResponse[1]/ns1:nodeName[1]}' )
Now you have created a soapUI property via DataGen named yourprop. You can use this property within the test suite for the following test cases.
I hope this helps, if you are not satisfied or you face any problem please let me know I will do my best.
来源:https://stackoverflow.com/questions/12905735/soapui-pro-transfering-a-xml-node-from-a-testcase-to-another