How to send a SOAP XML message using the SendRequest method
The user wants to write a test that sends a SOAP XML message to his Web Services gateway.
Example:
Set ssr0XML = XMLUtil.CreateXMLFromFile("D:\temp\XML\ServiceStatus\SSR0.xml")
WebService("XOAService_2").SendRequest("ServiceStatus", "ssr0XML")
The first line of the script reads the contents of a valid XML file into a variable named ssr0XML. The second line attempts to send this message to the Web Services application server.
During replay, the user verifies that QuickTest Professional sends the message. However, the content of the message is the string ssr0XML, not the expected XML file. This causes the Web Services server to generate an error. How should a message be sent?
Solution: Using the SendRequest Web Services method
The SendRequest method sends the message specified in the SOAPMessage argument with no modifications and no additional items are appended to the message. Specifically, the message is not affected by previous AddAttachment, AddHeader, AddMessageProtection, AddSecurityToken statements.
object.SendRequest OperationName, SOAPMessage
object The WebService test object.
OperationName The Web service operation to be performed by the request.
SOAPMessage The SOAP request in the form of an XML string. The value should be a valid SOAP envelope, according to the SOAP specifications.
You can retrieve the response to the message sent with this method by inserting a LastResponse statement after it.
Note:
The SendRequest method expects a XML string, not an XML object. So if you are using the XMLUtil object to create an XML object, you will need to use the ToString method to convert the XML object to an XML string. Then you can use it with the SendRequest method.
Example:
Set ssr0XML = XMLUtil.CreateXMLFromFile("D:\temp\XML\ServiceStatus\SSR0.xml")
XMLstr = ssr0XML.ToString
WebService("XOAService_2").SendRequest("ServiceStatus", XMLstr)
Source
If you want to keep track of further articles on QTP. I recommend you to subscribe via RSS Feed. You can also subscribe by Email and have new QTP articles sent directly to your inbox.
Sending SOAP XML message using QTP
Subscribe to:
Post Comments (Atom)

11 comments:
Hi!
It would be nice to see an example with real WSDL-Service.
Thanks.
What libruery should I include to allow function WebService?
Hi Ankur,
This is chandra, I need your hlp..
I am working in Webservices, but I am new to this can plz tell me how to start working on it...
I don't know how to send requst and take response....
Can you plz help me...if posible plz send one example..
chandra.rao@enfs.com.
Thanks
-- Chandra
can someone pl. share a detailed example. I tried a few different things, but can seem to get the response from teh soap post.
i tried following
Set ssr0XML= XMLUtil.CreateXMLFromFile("G:\work related\Automation\Webservices\XMLs\validate email")
XMLstr = ssr0XML.ToString
WebService("ValidateEmailService").SendRequest "Isvalidate", XMLstr
but i m getting error "The constructor to deserialize an object of type 'Mercury.QTP.WS.NET_Client.NetToolkitException' was not found."...
please any one knows how to solve this.....?
Hey everyone. I had a hell of a time getting QTP to call a web service successfully but finally got it working using the code below:
Set ssr0XML = XMLUtil.CreateXMLFromFile("C:\ScheduleRequest.xml")
XMLstr = ssr0XML.ToString
Set RequestSchedule = WebService("AutomatedSchedulingService").RequestSchedule(XMLstr)
I was having all sorts of issues with invalid characters and internal server (500) errors using the xml generated by the QTP WebService wizard. Finally I just went ahead and manually constructed the xml and hey presto!
Hope this helps.
Hi Ankur,
I'm new to QTP - learning from various sites and the UserGuide. In your example above, how do you get the webservices name. Or in other words, can you provide a detailed example for WebServices. Your help is much appreciated.
Thanks
Ruby
The Web Service name comes from the wsdl after you loaded using QTP Services Wizard. Once you do at least one API selection, the service will be loaded in your object repository.
We also constructed our own XML file and using raw WebService("X").SendRequest method.
One problem that I have is that QTP does not seem to be able to capture valid/detailed error message (e.g. No record found). GetLastError or LastResponse methods will only contain generic 500 error.
Did anyone found way to retrieve detailed error messages?
I successfully used Keyword View and Datatable combination and got the Web Service Working. There are a couple of things to explain before we start the webservices. I used QTP 10 for web services. Keyword View, Data Table and inbuilt XML check points are only necessary to for successfully testing web services in most of the cases. if we are going for descriptive programming i will say we are not making use of most of the built in facilities provided by QTP as - is and re-inventing the wheel. I will host a simple example in You Tube and will place the link here for your reference. I am searching for some recording tools and screen captureing mechanism.
@Chad: You can contact me using the contact form http://www.learnqtp.com/contact/
@Chad...would you mind to post your link for your example. Thx much!
Post a Comment