D
Drak23
All:
What is the best way to optimize a SOAP call to a web
service in VBA? Bear in mind this is in Word 97 on
Windows NT. A previous developer on an app I inherited
created the following CallService routine. Calls to this
procedure are made many times when the app initializes,
passing various web method names and pulling back varying
quantities of data (totalling around 2MB of XML data).
My question - calls to DoEvents are strung together in
several places. Liberal use of DoEvents is generally a
good idea in Word97 VBA, but this seems a little
excessive. Is this necessary? If so why? Is there a
better way free up the process?
====================================================
Public Function CallService(strServiceName As String,
strMethodName As String, ParameterArr() As String, ByRef
retDOMDoc As DOMDocument40) As Boolean
Dim Connector As SoapConnector30
Dim Serializer As SoapSerializer30
Dim Reader As SoapReader30
Dim I As Integer
On Error GoTo Err_Handler
DoEvents
Set Connector = New HttpConnector30
Set Serializer = New SoapSerializer30
Set Reader = New SoapReader30
'Set up the SOAP envelope (not shown)
SetSoapHeader Connector, Serializer, strServiceName,
strMethodName
'Bunch of DoEvents
DoEvents: DoEvents: DoEvents: DoEvents: DoEvents
'Set up parameters
For I = 1 To UBound(ParameterArr, 2)
Serializer.startElement ParameterArr(1, I)
'
Serializer.SoapAttribute "type", , "xsd:string", "xsi"
Serializer.SoapAttribute "type", , "xsd:" &
ParameterArr(3, I), "xsi"
Serializer.WriteString ParameterArr(2, I)
Serializer.endElement
DoEvents
Next
'More DoEvents
DoEvents: DoEvents: DoEvents
'Close up the SOAP envelope (not shown)
SetSoapFooter Connector, Serializer
Reader.Load Connector.OutputStream
'Still more DoEvents
DoEvents: DoEvents: DoEvents: DoEvents: DoEvents
If Not Reader.Fault Is Nothing Then
MsgBox Reader.FaultString.Text, vbExclamation
GoTo Err_Handler
Else
Set retDOMDoc = Reader.Dom
End If
Set Reader = Nothing
Set Serializer = Nothing
Set Connector = Nothing
CallService = True
Exit Function
Err_Handler:
CallService = False
Set Reader = Nothing
Set Serializer = Nothing
Set Connector = Nothing
What is the best way to optimize a SOAP call to a web
service in VBA? Bear in mind this is in Word 97 on
Windows NT. A previous developer on an app I inherited
created the following CallService routine. Calls to this
procedure are made many times when the app initializes,
passing various web method names and pulling back varying
quantities of data (totalling around 2MB of XML data).
My question - calls to DoEvents are strung together in
several places. Liberal use of DoEvents is generally a
good idea in Word97 VBA, but this seems a little
excessive. Is this necessary? If so why? Is there a
better way free up the process?
====================================================
Public Function CallService(strServiceName As String,
strMethodName As String, ParameterArr() As String, ByRef
retDOMDoc As DOMDocument40) As Boolean
Dim Connector As SoapConnector30
Dim Serializer As SoapSerializer30
Dim Reader As SoapReader30
Dim I As Integer
On Error GoTo Err_Handler
DoEvents
Set Connector = New HttpConnector30
Set Serializer = New SoapSerializer30
Set Reader = New SoapReader30
'Set up the SOAP envelope (not shown)
SetSoapHeader Connector, Serializer, strServiceName,
strMethodName
'Bunch of DoEvents
DoEvents: DoEvents: DoEvents: DoEvents: DoEvents
'Set up parameters
For I = 1 To UBound(ParameterArr, 2)
Serializer.startElement ParameterArr(1, I)
'
Serializer.SoapAttribute "type", , "xsd:string", "xsi"
Serializer.SoapAttribute "type", , "xsd:" &
ParameterArr(3, I), "xsi"
Serializer.WriteString ParameterArr(2, I)
Serializer.endElement
DoEvents
Next
'More DoEvents
DoEvents: DoEvents: DoEvents
'Close up the SOAP envelope (not shown)
SetSoapFooter Connector, Serializer
Reader.Load Connector.OutputStream
'Still more DoEvents
DoEvents: DoEvents: DoEvents: DoEvents: DoEvents
If Not Reader.Fault Is Nothing Then
MsgBox Reader.FaultString.Text, vbExclamation
GoTo Err_Handler
Else
Set retDOMDoc = Reader.Dom
End If
Set Reader = Nothing
Set Serializer = Nothing
Set Connector = Nothing
CallService = True
Exit Function
Err_Handler:
CallService = False
Set Reader = Nothing
Set Serializer = Nothing
Set Connector = Nothing