02-24-2011, 01:28 PM
Hi ugandhar,
You can use web Service testing Wizard provided by QTP for testing webservices. Else can be done using WinHttpRequest object.
First Create an properly formatted request XML.
'Create Object of WinHttp.WinHttpRequest.5.1
'Configure timeouts in milliseconds (Resolve, Connect, Send, Receive).
'Open [POST] connection to Web Service via WinHttpRequest object.
'Configure HTTP request header properties.
'Define connection values.
= *****
'Send connection authorization credentials.
'Send request input as a properly formatted XML string.
'Reference response text
Verify what ever Tag you want to verify.
You can use web Service testing Wizard provided by QTP for testing webservices. Else can be done using WinHttpRequest object.
First Create an properly formatted request XML.
'Create Object of WinHttp.WinHttpRequest.5.1
Code:
Set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
Code:
WinHttpReq.SetTimeouts 30000, 30000, 30000, 30000
Code:
WinHttpReq.Open "POST", ServerName, False
Code:
WinHttpReq.SetRequestHeader "Content-Type", "text/xml;charset=utf-8"
WinHttpReq.SetRequestHeader "Accept", "text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
WinHttpReq.SetRequestHeader "Content-Transfer-Encoding", "binary"
WinHttpReq.SetRequestHeader "Connection", "keep-alive"
'Define connection values.
Code:
HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0
UserName = "XYZ"
Password
'Send connection authorization credentials.
Code:
WinHttpReq.SetCredentials UserName, Password, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
Code:
WinHttpReq.Send(strXML)
Code:
sResponseText = CStr(WinHttpReq.ResponseText)
Verify what ever Tag you want to verify.