OnPreSendSOAPRequest - cClientWebService
Sent right before an HTTP SOAP request is sent, providing one last chance to alter the SOAP request or the HTTP information
Type: Event
Parameters
| Parameter | Type | Description |
|---|---|---|
| hoSOAPXml | Handle | This is the SOAP xml document to be sent. If you change this, the changed document will be sent. |
| hoHttp | Handle | This is the http object performing the post. The cXmlHttpTransfer object has all properties set. If you change this, it will change the HTTP post. |
| ByRef sHost | String | This is the host value that will sent to the cXmlHttpTransfer HttpPostXmlNode method. This is passed by reference and can be changed. |
| ByRef sFilePath | String | This is the file path value that will sent to the cXmlHttpTransfer HttpPostXmlNode method. This is passed by reference and can be changed. |
Syntax
Procedure OnPreSendSOAPRequest Handle hoSOAPXml Handle hoHttp ByRef String sHost ByRef String sFilePath
Description
OnPreSendSOAPRequest is sent right before a SOAP request is sent to the server. It passes all of the data that will make this HTTP post. It passes:
This event does nothing by default and exists for two purposes.
-
This can be a useful debugging point allowing you to see exactly what is being sent, where it is being set and how it is being set. Just add the event to your client web service object and place a breakpoint on the End_Procedure. You can see exactly what is being sent.
-
This can also be used to change what will be sent. For SOAP, XML and the HTTP object are passed via handles and can be altered. The host and file path parameters are passed by reference and can be changed. Changing any of these should be considered advanced technique and hopefully will not be required. If required, you will probably be changing the SOAP XML data. You might need to do this if there is a mismatch between the SOAP document created by the client and what is expected by the server.
The most likely cause of a mismatch might be the need to not pass certain nodes. You could use this event to remove those nodes. If this is an issue, this is most likely a case of not wanting pass minOccurs=0 parameters to the server. This can be better handled when importing the web-service. If you check the "Support Structs with Null member" and "Support Simple types with Null member" checkbox options, the class will support minOccurs=0 "null" types by allowing you to set variable values to null. It is recommended that you try this first.
Sample
In this example, we will search for an XML node and remove it. This is the sort of thing you do as a last resort.
Procedure OnPreSendSOAPRequest Handle hoSOAPXml Handle hoHttp String ByRef sHost String ByRef sFilePath
Handle hoParam hoParent
String sNS
Move ("xmlns:e='http://www.ups.com/XMLSchema/XOLTWS/xav/v1.0'" ) to sNS
Set psSelectionNamespaces of hoSOAPXml to sNS
Get FindNode of hoSOAPXml "descendant::e:RegionalRequestIndicator" to hoParam
If hoParam Begin
Get ParentNode of hoParam to hoParent
Get RemoveNode of hoParent hoParam to hoParam
Send Destroy of hoParam
Send Destroy of hoParent
End
End_Procedure