How to use the "Scripted XML" option

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in SOAtest
to generate XML within a SOAP Client
The following example shows how to use the "Scripted XML" option within a SOAP Client to dynamically generate XML.

To use this example:
1. Create a SOAP Client
2. Enter "http://soaptest.parasoft.com/calculator.wsdl" for the WSDL URI
3. Change the SOAP Envelope combo box to "Scripted XML"
4. Enter the script shown below into the text window
5. Make sure that "getBody()" is the selected method
5. Run the test and view the traffic.

CODE
prefix = """<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
 <add xmlns="http://www.parasoft.com/wsdl/calculator/">"""

suffix = """</add>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>"""

def getBody():
   number1 = 5
   number2 = 10
   return prefix + "<x>" + str(number1) + "</x>" + "<y>" + str(number2) + "</y>" + suffix
Tagged:

Comments

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Thanks for the script. I have a question related to it.

    Is there a way to use scripted xml with a data source for parameterized testing?
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    There is not currently an easy way to do this, however I will file it as a feature request.

    Josh
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    QUOTE(jhendrick @ Jul 12 2004, 10:40 AM)
    There is not currently an easy way to do this, however I will file it as a feature request.

    Josh

    Hi,

    Has this feature request ever been implemeted? We desperately need this functionality for our HTTP Client and SOAP testing.

    Thanks!
Sign In or Register to comment.