The Simple Object Access Protocol (SOAP) is a lightweight, XML-based protocol for exchanging information in a decentralized, distributed environment. As such, SOAP provides an open methodology for application-to-application communication known as XML Web services.
The Microsoft® Simple Object Access Protocol (SOAP) Toolkit 3.0 consists of the following components:
A client-side component that allows an application to invoke XML Web service operations described by a Web Services Description Language (WSDL) file. This WSDL file describes the service(s) and operations of the service offered by the server.
A server-side component that maps invoked XML Web service operations to COM object method calls as described by the WSDL and Web Services Meta Language (WSML) files. The WSML file is necessary for the implementation of the Microsoft SOAP Toolkit.
The components needed to construct, transmit, read, and process SOAP messages. These processes are collectively referred to as marshalling and unmarshalling.
In addition, the SOAP Toolkit provides a WSDL/WSML Generator tool that generates the WSDL and WSML files for you, relieving you of the tedious process of manually creating such files.
SOAP Toolkit 3.0 download: http://www.microsoft.com/downloads/details.aspx?familyid=c943c0dd-ceec-4088-9753-86f052ec8450&displaylang=en
The Microsoft SOAP Toolkit is deprecated by the .NET Framework. The toolkit provides basic Web services capabilities for COM components and applications. SOAP Toolkit support has been extended from the originally posted July 1, 2004 deadline. Mainstream SOAP Toolkit support will now be retired in March 31, 2005 with extended support lasting until March 31, 2008.
The following example illustrates the basic steps to use SOAP with PowerBASIC using Automation.
' ########################################################################################
' SOAP example using Automation.
' ########################################################################################
' SED_PBWIN - Use the PBWIN compiler
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN () AS LONG
LOCAL oSoapClient AS DISPATCH
LOCAL vWSDLFile AS VARIANT
LOCAL vCategory AS VARIANT
LOCAL vRes AS VARIANT
' oSoapClient = NEWCOM "MSSOAP.SoapClient30" ' SOAP 3.0
' oSoapClient = NEWCOM "MSOSOAP.SoapClient30" ' version installed with Office 11
' oSoapClient = NEWCOM "MSSOAP.SoapClient.1" ' SOAP 1.0
oSoapClient = NEWCOM "MSSOAP.SoapClient" ' SOAP 1.0 - version independent ProgID
IF ISNOTHING(oSoapClient) THEN EXIT FUNCTION
TRY
LET vWSDLFile = "http://www.interpressfact.net/webservices/getJoke.asmx?wsdl"
OBJECT CALL oSoapClient.MSSoapInit(vWSDLFile)
' Categories:
' Murphy's Laws - 7
' Q&A - 3
' Unnatural Laws - 18
' Cool Jokes - 6
' Blondes - 2
' Random(contains Adult) - 1
' Lawyers - 5
' Headlines - 8
' Military - 9
' Accidents - 4
' Excuses - 10 [out of range]
' Answering machine - 11 [out of range]
' All categories - 0
vCategory = 8
OBJECT CALL oSoapClient.getJoke(vCategory) TO vRes
MSGBOX VARIANT$(vRes)
CATCH
OBJECT GET oSoapClient.FaultString TO vRes
MSGBOX VARIANT$(vRes)
FINALLY
oSoapClient = NOTHING
END TRY
END FUNCTION
The following version uses a mix of Automation and direct interface calls.
' ########################################################################################
' SOAP example mixing direct calls and Automation.
' ########################################################################################
' SED_PBWIN - Use the PBWIN compiler
#COMPILE EXE
#DIM ALL
#INCLUDE "MSSOAP1.INC" ' SOAP 1.0
'#INCLUDE "MSSOAP30.INC" ' SOAP 3.0
'#INCLUDE "MSOSOAP30.INC" ' SOAP 3.0 for Office
FUNCTION PBMAIN () AS LONG
LOCAL pSoapClient AS ISoapClient ' SOAP 1.0
' LOCAL pSoapClient AS ISoapClient30 ' SOAP 3.0
LOCAL oSoapClient AS DISPATCH
LOCAL vCategory AS VARIANT
LOCAL vRes AS VARIANT
' pSoapClient = NEWCOM "MSSOAP.SoapClient30" ' SOAP 3.0
' pSoapClient = NEWCOM "MSOSOAP.SoapClient30" ' SOAP 3.0 for Office
' pSoapClient = NEWCOM "MSSOAP.SoapClient.1" ' SOAP 1.0
' pSoapClient = NEWCOM "MSOSOAP.SoapClient" ' SOAP 1.0 - version independent ProgID
pSoapClient = NEWCOM "MSSOAP.SoapClient" ' SOAP 1.0 - version independent ProgID
IF ISNOTHING(pSoapClient) THEN EXIT FUNCTION
oSoapClient = pSoapClient
TRY
' Note Despite being flagged as optional, if we don't specify the second
' and third parameters (service name and port name) when using a direct call
' it returns error &H80070057 (wrong parameter). This doesn't happens if we
' use Automation.
pSoapClient.MSSoapInit( _
UCODE$("http://interpressfact.net/webservices/getjoke.asmx?wsdl"), _
UCODE$("getJoke"), UCODE$("getJokeSoap"))
' Categories:
' Murphy's Laws - 7
' Q&A - 3
' Unnatural Laws - 18
' Cool Jokes - 6
' Blondes - 2
' Random(contains Adult) - 1
' Lawyers - 5
' Headlines - 8
' Military - 9
' Accidents - 4
' Excuses - 10 [out of range]
' Answering machine - 11 [out of range]
' All categories - 0
vCategory = 8
OBJECT CALL oSoapClient.getJoke(vCategory) TO vRes
MSGBOX VARIANT$(vRes)
CATCH
MSGBOX ACODE$(pSoapClient.FaultString)
FINALLY
oSoapClient = NOTHING
pSoapClient = NOTHING
END TRY
END FUNCTION
The following version uses direct interface calls only.
' ########################################################################################
' SOAP example using direct calls exclusively.
' ########################################################################################
' SED_PBWIN - Use the PBWIN compiler
#COMPILE EXE
#DIM ALL
#INCLUDE "MSSOAP1.INC" ' SOAP 1.0
'#INCLUDE "MSSOAP30.INC" ' SOAP 3.0
'#INCLUDE "MSOSOAP30.INC" ' SOAP 3.0 for Office
FUNCTION PBMAIN () AS LONG
LOCAL pSoapClient AS ISoapClient ' SOAP 1.0
' LOCAL pSoapClient AS ISoapClient30 ' SOAP 3.0
LOCAL hr AS LONG
LOCAL dispId AS LONG
LOCAL IID_NULL AS GUID
LOCAL strName AS STRING
LOCAL vResult AS VARIANT
DIM vArgs(0) AS VARIANT
LOCAL tDispParams AS DISPPARAMS
' pSoapClient = NEWCOM "MSSOAP.SoapClient30" ' SOAP 3.0
' pSoapClient = NEWCOM "MSOSOAP.SoapClient30" ' SOAP 3.0 for Office
' pSoapClient = NEWCOM "MSSOAP.SoapClient.1" ' SOAP 1.0
' pSoapClient = NEWCOM "MSOSOAP.SoapClient" ' SOAP 1.0 - version independent ProgID
pSoapClient = NEWCOM "MSSOAP.SoapClient"
IF ISNOTHING(pSoapClient) THEN EXIT FUNCTION
TRY
' Note Despite being flagged as optional, if we don't specify the second
' and third parameters (service name and port name) when using a direct call
' it returns error &H80070057 (wrong parameter). This doesn't happens if we
' use Automation.
pSoapClient.MSSoapInit( _
UCODE$("http://interpressfact.net/webservices/getjoke.asmx?wsdl"), _
UCODE$("getJoke"), UCODE$("getJokeSoap"))
' Categories:
' Murphy's Laws - 7
' Q&A - 3
' Unnatural Laws - 18
' Cool Jokes - 6
' Blondes - 2
' Random(contains Adult) - 1
' Lawyers - 5
' Headlines - 8
' Military - 9
' Accidents - 4
' Excuses - 10 [out of range]
' Answering machine - 11 [out of range]
' All categories - 0
strName = UCODE$("getJoke")
hr = pSoapClient.GetIDsOfNames(IID_NULL, strName, 1, 0, dispId)
IF hr = %S_OK THEN
vArgs(0) = 8
tDispParams.CountArgs = 1
tDispParams.VariantArgs = VARPTR(vArgs(0))
hr = pSoapClient.Invoke(dispId, IID_NULL, 0, %DISPATCH_METHOD, tDispParams, _
vResult, BYVAL %NULL, BYVAL %NULL)
IF hr = %S_OK THEN MSGBOX VARIANT$(vResult)
END IF
IF hr <> %S_OK THEN MSGBOX ACODE$(pSoapClient.FaultString)
CATCH
' Display error information
MSGBOX ACODE$(pSoapClient.FaultString)
FINALLY
' Release the object
pSoapClient = NOTHING
END TRY
END FUNCTION
I have installed Soap Toolkit 3.0, and MS Framework, but I get error message: Missing Declaration: NEWCOM when running the code.
There is something wrong with: "MSSOAP.SoapClient" What can I do?
Martin
Quote
I get error message: Missing Declaration: NEWCOM when running the code.
To use
NEWCOM you need PBWIN 9.0+ or PBCC 5.0+. All the code posted in this forum needs the new compilers. For older versions, all what we have available can be found in the
Legacy Software forum, at the bottom.
Thanks a lot for reply!
I am used to work with PBCC, but I am not used to work with all this SOAP stuff.
I am working on a project to get data with the help of a self written SOAP client.
Login to betfair, and get informations according to "Betfair Sports Exchange API Reference Guide v6" on "http://bdpsupport.betfair.com/ics/support/default.asp?deptID=2805&task=download"
The future program should be a Betfair-Bot.
Is there any kind of code showing how to login, or how to get information e.g. "MarketPrices, getCurrentBets, ......"
For me it would be important to find the starting point.
Martin
I don't have specific examples for Betfair.
To initialize SOAP, use:
pSoapClient.MSSoapInit( _
UCODE$("https://api.betfair.com/global/v3/BFGlobalService.wsdl"), _
UCODE$("BFGlobalService"), UCODE$("BFGlobalService"))
or this one if you are using an older version of the compiler:
LOCAL vWSDLFile AS VAEIANT
LOCAL vServiceName AS VARIANT
LOCAL vPort AS VARIANT
LET vWSDLFile = "http://www.interpressfact.net/webservices/getJoke.asmx?wsdl"
vServiceName = "BFGlobalService"
vPort = "BFGlobalService"
OBJECT CALL oSoapClient.MSSoapInit(vWSDLFile, vServiceName, vPort)
Then call the wanted service, e.g. OBJECT CALL oSoapClient.GetCurrentBets (<parameters>).
The parameters that you have to pass are specified in the documentation provided by Betfair: http://bdpsupport.betfair.com/ics/support/default.asp?deptID=2805&task=download
I had poor results ever with the office version.
Have you tested this fella with succes?
It seems the older release has no more support, running it as a simple unregisterd dll will not work as well.
That's to bad, a self contained dll would have been nice.
(I did not test your code)
FYI, i have a webservice running at:
http://www.hellobasic.com/webservices/test1.asmx
It may be useful to test with this ASP.NET webservice.
Some instructions are also in this topic:
http://www.hellobasic.com/cgi-bin/forum/YaBB.pl?board=VDExamples;action=display;num=1202649022
oSoapClient.MSSoapInit(UCODE$("https://api.betfair.com/global/v3/BFGlobalService.wsdl"), _
UCODE$("BFGlobalService"), UCODE$("BFGlobalService"))
Here I get error message: Method or Property name expected
I have posted that if you are using an older version of the compiler you will have to use:
LOCAL vWSDLFile AS VAEIANT
LOCAL vServiceName AS VARIANT
LOCAL vPort AS VARIANT
LET vWSDLFile = "http://www.interpressfact.net/webservices/getJoke.asmx?wsdl"
vServiceName = "BFGlobalService"
vPort = "BFGlobalService"
OBJECT CALL oSoapClient.MSSoapInit(vWSDLFile, vServiceName, vPort)
Do not try to use code written for PBWIN 9/PBCC 5 with PBCC 4.
I can not call the wanted service. :-[
#COMPILE EXE
#DIM ALL
'#INCLUDE "MSSOAP1.INC" ' SOAP 1.0
'#INCLUDE "MSSOAP30.INC" ' SOAP 3.0
#INCLUDE "MSOSOAP30.INC" ' SOAP 3.0 for Office
FUNCTION PBMAIN () AS LONG
' LOCAL pSoapClient AS ISoapClient ' SOAP 1.0
LOCAL pSoapClient AS ISoapClient30 ' SOAP 3.0
LOCAL hr AS LONG
LOCAL dispId AS LONG
LOCAL IID_NULL AS GUID
LOCAL strName AS STRING
LOCAL vResult AS VARIANT
DIM vArgs(0) AS VARIANT
LOCAL tDispParams AS DISPPARAMS
LOCAL vRes AS VARIANT
pSoapClient = NEWCOM "MSSOAP.SoapClient"
IF ISNOTHING(pSoapClient) THEN EXIT FUNCTION
pSoapClient.MSSoapInit(UCODE$("https://api.betfair.com/global/v3/BFGlobalService.wsdl"), _
UCODE$("BFGlobalService"), UCODE$("BFGlobalService"))
hr = pSoapClient.BFGlobalService.APIRequestHeader(clientStampField) TO vRes
MSGBOX VARIANT$(vRes)
END FUNCTION
It should be something like:
' ########################################################################################
' SOAP example using Automation.
' ########################################################################################
' SED_PBWIN - Use the PBWIN compiler
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN () AS LONG
LOCAL oSoapClient AS DISPATCH
LOCAL vWSDLFile AS VARIANT
LOCAL vClientStampField AS VARIANT
LOCAL vRes AS VARIANT
oSoapClient = NEWCOM "MSSOAP.SoapClient"
IF ISNOTHING(oSoapClient) THEN EXIT FUNCTION
TRY
vWSDLFile = UCODE$("https://api.betfair.com/global/v3/BFGlobalService.wsdl")
OBJECT CALL oSoapClient.MSSoapInit(vWSDLFile)
' vClientStampField = "<some name>" ' <--- change me
' OBJECT CALL oSoapClient.APIRequestHeader(vClientStampField) TO vRes
' MSGBOX VARIANT$(vRes)
CATCH
OBJECT GET oSoapClient.FaultString TO vRes
MSGBOX VARIANT$(vRes)
FINALLY
oSoapClient = NOTHING
END TRY
END FUNCTION
If it doesn't work, I don't know what more to do. Other than the posted example, I never have done anything with SOAP.