Proble with VBA, SOAP and XML

D

dysgraphia

Using XP and Office 2000 on one box
XP pro and Office 2003 on another.
This question was previously posted to the m.p.xml group but after
6 days got no response at all so maybe this group is more appropriate.

A bit of preamble.
My project is to use VBA, SOAP, XML to consume web services
provided by a pari-mutuel totalisator web site
using the Web Service Reference Tool in Excel.
Each day a unique key is allocated to the user
who has previously registered at the site which provides
this as a free service to customers so that they may
access the live data feed.The site recommends the user to
develop code to access the live feed via XML and VBA.
In the VB editor I entered the Web Service URL provided and
downloaded the two class modules clsws_Login and clsws_Racing.
The clsws_Login is used to retrieve the day's key then this key is
used together with other login parameters to get live data using
the clsws_Racing class. The code for the class modules follows
after my effort TestOfLogin.

In order to retrieve the key I tried the following but all
I get is a connection timeout when implemented on either box.
Any suggestions as to how to get this project running will be
appreciated!......cheers, pete
NB: The key is 32 bit and will be just passed as a variable
in subsequent code.

Sub TestOfLogin()
' Retrieve the daily Key...
Dim objS As clsws_Login
Dim myKey As String
Dim str_userName As String
Dim str_password As String

str_userName = "***************"
str_password = "********"

Set objS = New clsws_Login

MyKey = objS.wsm_GetKey(str_userName, str_password)

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''
The code in the login class module clsws_Login is:
All comments were provided with the module on download.
'*****************************************************************
'This class was created by the Web Service References Tool 2.0.
'This class is a Visual Basic for Applications class representation of
the Web service
'as defined by
https://direct.racetab.com.au/LiveOdds/Services/Login/Login.asmx?wsdl.
'To Use:
'Dimension a variable as new clsws_Login, and then write code to
'use the methods provided by the class.
'Example:
' Dim ExampleVar as New clsws_Login
' debug.print ExampleVar.wsm_GetKey("Sample Input")
'*****************************************************************

'Dimensioning private class variables.
Private sc_Login As SoapClient30 'SoapClient30
Private Const c_WSDL_URL As String =
"https://direct.racetab.com.au/LiveOdds/Services/Login/Login.asmx?wsdl"
Private Const c_SERVICE As String = "Login"
Private Const c_PORT As String = "LoginSoap"
Private Const c_SERVICE_NAMESPACE As String =
"http://racetab.com.au/LiveOdds/"

Private Sub Class_Initialize()
'*****************************************************************
'This subroutine will be called each time the class is instantiated.
'Creates sc_ComplexTypes as new SoapClient30, and then
'initializes sc_ComplexTypes.mssoapinit2 with WSDL file found in
'https://direct.racetab.com.au/LiveOdds/Services/Login/Login.asmx?wsdl.
'*****************************************************************

Dim str_WSML As String
str_WSML = ""

Set sc_Login = New SoapClient30 'SoapClient30

sc_Login.MSSoapInit2 c_WSDL_URL, str_WSML, c_SERVICE, c_PORT,
c_SERVICE_NAMESPACE
'Use the proxy server defined in Internet Explorer's LAN settings by
'setting ProxyServer to <CURRENT_USER>
sc_Login.ConnectorProperty("ProxyServer") = "<CURRENT_USER>"
'Autodetect proxy settings if Internet Explorer is set to autodetect
'by setting EnableAutoProxy to True
sc_Login.ConnectorProperty("EnableAutoProxy") = True

End Sub

Private Sub Class_Terminate()
'*****************************************************************
'This subroutine will be called each time the class is destructed.
'Sets sc_ComplexTypes to Nothing.
'*****************************************************************

'Error Trap
On Error GoTo Class_TerminateTrap

Set sc_Login = Nothing

Exit Sub

Class_TerminateTrap:
LoginErrorHandler ("Class_Terminate")
End Sub

Private Sub LoginErrorHandler(str_Function As String)
'*****************************************************************
'This subroutine is the class error handler. It can be called from
any class subroutine or function
'when that subroutine or function encounters an error. Then, it
will raise the error along with the
'name of the calling subroutine or function.
'*****************************************************************

'SOAP Error
If sc_Login.FaultCode <> "" Then
Err.Raise vbObjectError, str_Function, sc_Login.FaultString
'Non SOAP Error
Else
Err.Raise Err.Number, str_Function, Err.Description
End If

End Sub

Public Function wsm_GetKey(ByVal str_userName As String, ByVal
str_password As String) As String
'*****************************************************************
'Proxy function created from
https://direct.racetab.com.au/LiveOdds/Services/Login/Login.asmx?wsdl.
'*****************************************************************

'Error Trap
On Error GoTo wsm_GetKeyTrap

wsm_GetKey = sc_Login.GetKey(str_userName, str_password)

Exit Function
wsm_GetKeyTrap:
LoginErrorHandler "wsm_GetKey"
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top