Description
Use the AddHeader
method of the WebServiceHelper
object to add custom SOAP header blocks to the Header element in requests sent to and responses received from your tested web service.
Declaration
WebServiceHelperObj.AddHeader(Name, Namespace, Value)
WebServiceHelperObj | An expression, variable or parameter that specifies a reference to a WebServiceHelper object | |||
Name | [in] | Required | String | |
Namespace | [in] | Required | String | |
Value | [in] | Required | Variant | |
Result | None |
Applies To
The method is applied to the following object:
Parameters
The method has the following parameters:
Name
Specifies the name of a SOAP header.
Namespace
Specifies the namespace of a SOAP header.
Value
Specifies the content of a SOAP header.
Result Value
None.
Remarks
The WebServiceHelper
object is used within the OnWebServiceRequest
and OnWebServiceResponse
event handlers.
Example
The following example demonstrates how to add custom SOAP headers to your web service requests in the OnWebServiceRequest
event handler:
JavaScript, JScript
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
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
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
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
WebServiceHelper Object
OnWebServiceRequest Event
OnWebServiceResponse Event
Testing Web Services
Adding Custom Headers to SOAP Requests