< (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.
- Create a custom code activity.
- Create an input parameter with a string value that will hold the XML response.
- 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.
- In the custom code activity, add the Execute Event handler.
- 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
- To save, depending on what was linked to, use the built in .NET Framework file saving functionality:
- It's recommended to add exception handling to the code.
- Reuse the event handler method where required.
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