QTP and HTTP

Question ID: 104452
0
0

Does anyone know how to construct a HTTP POST request for a web service using QTP 10? I have a WCF web service that I need to pass a cookie in this manner before sending the xml request. Any help would be appreciated.

Marked as spam
Posted by (Questions: 2, Answers: 3)
Asked on January 25, 2012 4:30 pm
23 views
Answers (2)
1
Private answer

Since QTP is vbscript, you can use CreateObject. Look at the Microsoft.XmlHttp samples with the open and send functions.

xmlhttp.Open ''GET'', ''SomeURL''

xmlhttp.setRequestHeader ''name'', ''value''

xmlhttp.send YourData

Marked as spam
Posted by (Questions: 1, Answers: 3)
Answered on March 6, 2012 11:53 am
0
Private answer

Thanks, I think that will work. But I did need to have it attached to a web service request. I found that the action ''.Headers.AddHTTPHeader'' did what I needed it to do.

Example:
WebService(''WebServiceName'').Headers.AddHTTPHeader''Name'', ''Value''

I also discovered that HP's help on Service Test 11 was incorrect. If they have not updated it yet the correct implementation is to place the following code in the user code of the ''OnSendRequest'' event.

Code:
This.StServiceCallActivity4.HttpRequestHeaders[''name''] = ''value'';

Marked as spam
Posted by (Questions: 2, Answers: 3)
Answered on March 6, 2012 12:10 pm