Highlighted
Absent Member.. vzamoraz Absent Member..
Absent Member..
392 views

< (UFT) Support tip> " How to Save an XML Response to a Text File programmatically"

There are a number of ways to save the XML response from a web service. Each approach will have their own positives depending upon your specific need.

 

This is an example of how saving an XML response might be accomplished with a custom coding activity.

  1. Create a custom code activity.
  2. Create an input parameter with a string value that will hold the XML response.
  3. Link that input parameter to the response body of the activity you where want to get the XML - it's in the output properties under checkpoints when linking.
  4. In the custom code activity, add the Execute Event handler.
  5. Access the input values to the custom coding activity with something like this:
    string s = this.CodeActivity.Input.imputpar; // the name of the input parameter that was created in #2 is "imputpar" for this sample
  6. To save, depending on what was linked to, use the built in .NET Framework file saving functionality:
    WriteAllText(@"c:\MyXMLResult.xml", s);
  7. It's recommended to add exception handling to the code.
  8. Reuse the event handler method where required.

 

 

HP support
If you find this useful, mark Kudos.
Note: The Opinions expressed in my post are mine alone, and do not reflect the opinions of my employer. No warranties express or implied for any answered posted.

 

DISCLAIMER OF WARRANTY
The example software is experimental and is provided as a courtesy, free of charge, "AS-IS" by Hewlett-Packard Development Company, L.P. ("HP"). HP shall have no obligation to maintain or support this software. HP MAKES NO EXPRESS OR IMPLIED WARRANTY OF ANY KIND REGARDING THIS SOFTWARE. HP SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, WHETHER BASED ON CONTRACT, TORT OR ANY OTHER LEGAL THEORY, IN CONNECTION WITH OR ARISING OUT OF THE FURNISHING, PERFORMANCE OR USE OF THIS SOFTWARE

 

Labels (1)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.