WebServiceHelper Object

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

WebServiceHelper is a helper object that is used within the OnWebServiceRequest and OnWebServiceResponse event handlers. The object has only one method, AddHeader, that allows adding custom SOAP header blocks to requests and responses of your tested web service.

Members

Example

The following example demonstrates how to add custom SOAP headers to a SOAP request:

JavaScript, JScript

// The routine calls the ProcessData method of the tested web service
function Main()
{

  WebServices.SampleWebService.ProcessData();

}

// The OnWebServiceRequest event handler
function GeneralEvents_OnWebServiceRequest(Sender, Request, Helper, RequestInfo)
{

  // Add a UserID header to the SOAP request
  Helper.AddHeader("UserID", "http://tempuri.org/", "jsmith");
  // Add a UserID header to the SOAP request
  Helper.AddHeader("Password", "http://tempuri.org/", "25jeL3n");

}

Python

# The routine calls the ProcessData method of the tested web service
def Main():
  WebServices.SampleWebService.ProcessData()

# The OnWebServiceRequest event handler
def GeneralEvents_OnWebServiceRequest(Sender, Request, Helper, RequestInfo):
  # Add a UserID header to the SOAP request
  Helper.AddHeader("UserID", "http://tempuri.org/", "jsmith")
  # Add a UserID header to the SOAP request
  Helper.AddHeader("Password", "http://tempuri.org/", "25jeL3n")

VBScript

' The routine calls the ProcessData method of the tested web service
Sub Main

  WebServices.SampleWebService.ProcessData

End Sub

' The OnWebServiceRequest event handler
Sub GeneralEvents_OnWebServiceRequest(Sender, Request, Helper, RequestInfo)

  ' Add a UserID header to the SOAP request
  Call Helper.AddHeader("UserID", "http://tempuri.org/", "jsmith")
  ' Add a UserID header to the SOAP request
  Call Helper.AddHeader("Password", "http://tempuri.org/", "25jeL3n")

End Sub

DelphiScript

// The routine calls the ProcessData method of the tested web service
procedure Main();
begin

  WebServices.SampleWebService.ProcessData();

end;

// The OnWebServiceRequest event handler
procedure GeneralEvents_OnWebServiceRequest(Sender, Request, Helper, RequestInfo);
begin

  // Add a UserID header to the SOAP request
  Helper.AddHeader('UserID', 'http://tempuri.org/', 'jsmith');
  // Add a UserID header to the SOAP request
  Helper.AddHeader('Password', 'http://tempuri.org/', '25jeL3n');

end;

C++Script, C#Script

// The routine calls the ProcessData method of the tested web service
function Main()
{

  WebServices["SampleWebService"]["ProcessData"]();

}

// The OnWebServiceRequest event handler
function GeneralEvents_OnWebServiceRequest(Sender, Request, Helper, RequestInfo)
{

  // Add a UserID header to the SOAP request
  Helper["AddHeader"]("UserID", "http://tempuri.org/", "jsmith");
  // Add a UserID header to the SOAP request
  Helper["AddHeader"]("Password", "http://tempuri.org/", "25jeL3n");

}

See Also

Testing Web Services
OnWebServiceRequest Event
OnWebServiceResponse Event
Adding Custom Headers to SOAP Requests

Highlight search results