Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to use the "Scripted XML" option

LegacyForum
LegacyForum Posts: 1,664 ✭✭
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

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    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?
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    There is not currently an easy way to do this, however I will file it as a feature request.

    Josh
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    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!