Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Betfair API web service

Status
Not open for further replies.

billborric

Programmer
Jun 30, 2003
1
AU
I am trying to connect to the Betfair web service API with the following code...
Code:
LOCAL loBFGlobalService AS "XML Web Service"
* LOCAL loBFGlobalService AS "MSSOAP.SoapClient30"
* Do not remove or alter following line. It is used to support IntelliSense for your XML Web service.
*__VFPWSDef__: loBFGlobalService = [URL unfurl="true"]https://api.betfair.com/global/v3/BFGlobalService.wsdl[/URL] , BFGlobalService , BFGlobalService
LOCAL loException, lcErrorMsg, loWSHandler
TRY
    loWSHandler = NEWOBJECT("WSHandler",IIF(VERSION(2)=0,"",HOME()+"FFC\")+"_ws3client.vcx")
    loBFGlobalService = loWSHandler.SetupClient("[URL unfurl="true"]https://api.betfair.com/global/v3/BFGlobalService.wsdl",[/URL] "BFGlobalService", "BFGlobalService")
    * Call your XML Web service here.  ex: leResult = loBFGlobalService.SomeMethod()
    *login(request AS LoginReq) AS LoginResp

CATCH TO loException
    lcErrorMsg="Error: "+TRANSFORM(loException.Errorno)+" - "+loException.Message
    DO CASE
    CASE VARTYPE(loBFGlobalService)#"O"
        * Handle SOAP error connecting to web service
    CASE !EMPTY(loBFGlobalService.FaultCode)
        * Handle SOAP error calling method
        lcErrorMsg=lcErrorMsg+CHR(13)+loBFGlobalService.Detail
    OTHERWISE
        * Handle other error
    ENDCASE
    * Use for debugging purposes
    MESSAGEBOX(lcErrorMsg)
FINALLY
ENDTRY

SET TEXTMERGE ON
TEXT TO lcLogin NOSHOW PRETEXT 7
<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/envelope/"[/URL] xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
  <soap:Body>
    <login xmlns="[URL unfurl="true"]http://www.betfair.com/publicapi/v3/BFGlobalService/">[/URL]
      <request>
        <ipAddress xmlns="" />
        <locationId xmlns="">0</locationId>
        <password xmlns="">bfpassword</password>
        <productId xmlns="">82</productId>
        <username xmlns="">bfusername</username>
        <vendorSoftwareId xmlns="">0</vendorSoftwareId>
      </request>
    </login>
  </soap:Body>
</soap:Envelope>
ENDTEXT
SET TEXTMERGE OFF

TRY
        *loBFGlobalService .ConnectorProperty("Timeout") = 240000
        lcXML = loBFGlobalService.login(lcLogin)
        xmltocursor(lcXML)
        BROWSE
CATCH TO loException
    lcErrorMsg="Error: "+TRANSFORM(loException.Errorno)+" - "+loException.Message
    DO CASE
    CASE VARTYPE(loBFGlobalService)#"O"
        * Handle SOAP error connecting to web service
    CASE !EMPTY(loBFGlobalService.FaultCode)
        * Handle SOAP error calling method
        lcErrorMsg=lcErrorMsg+CHR(13)+loBFGlobalService.Detail
    OTHERWISE
        * Handle other error
    ENDCASE
    * Use for debugging purposes
    MESSAGEBOX(lcErrorMsg)
FINALLY
ENDTRY

...however the "lcXML = loBFGlobalService.login(lcLogin)" returns the following object...
error -

Client:Incorrect number of parameters supplied for SOAP request HRESULT=0x80070057: The parameter is incorrect.

The above XML was generated by a utility available on the Betfair site, but they also have some downloadable XML files which are slightly different...

Code:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="[URL unfurl="true"]http://schemas.xmlsoap.org/soap/envelope/"[/URL] xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
  <soap:Body>
    <login xmlns="[URL unfurl="true"]http://www.betfair.com/publicapi/v3/BFGlobalService/">[/URL]
      <request>
          <ipAddress xmlns=""></ipAddress>
        <locationId xmlns="">0</locationId>
        <password xmlns="">bfpassword</password>
        <productId xmlns="">82</productId>
        <username xmlns="">bfusername</username>
        <vendorSoftwareId xmlns="">0</vendorSoftwareId>
      </request>
    </login>
  </soap:Body>
</soap:Envelope>

...both forms generate the sane error.

Hoping someone can shed some light on this.
 
when i use this form of soap call you are creating an object in your case called loBFGlobalService.
with this object I do not build and pass the soap envelope and just set the properties and call the method
Code:
loBFGlobalService.locationId=0
loBFGlobalService.productId=82
loBFGlobalService.username="myUserName"
loBFGlobalService.password="myPassword"
lResult=loBFGlobalService.login()
another possiable iteration not knowing or looking at the wsdl would be
Code:
lResult=loBFGlobalService.login(lnLocationId,lnProductId,lcUser,lcPassword)
I am also assuming that LocationId and ProductId are numeric. This information can be found in the wsdl located at
I looked at the wsdl and indeed the ProductId and LocationId are looking for INT. Good Luck


Steve Bowman
Independent Technology, Inc.
CA, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top