WattersUK


I much experience in FoxPro (not any really), but I have been given a task to to try to access a Web Service.

I can define the service to access with the Task Pane easily enough but what I am having trouble doing is retrieving the data into a meaningful type when calling the method.

For e.g.

LOCAL ResultSet

LOCAL loGMWService AS "XML Web Service"
* LOCAL loGMWService AS "MSSOAP.SoapClient30"
* Do not remove or alter following line. It is used to support IntelliSense for your XML Web service.
*__VFPWSDef__: loGMWService = http://192.168.101.197/gmwservice/GMWService.asmx WSDL , GMWService , GMWServiceSoap
LOCAL loException, lcErrorMsg, loWSHandler

WITH THISFORM
TRY
loWSHandler = NEWOBJECT("WSHandler",IIF(VERSION(2)=0,"",HOME()+"FFC\")+"_ws3client.vcx")
loGMWService = loWSHandler.SetupClient("http://192.168.101.197/gmwservice/GMWService.asmx WSDL", "GMWService", "GMWServiceSoap")

* Call your XML Web service here. ex: leResult = loGMWService.SomeMethod()

ResultSet = loGMWService.GetNextRecords(.TxtGroupID.Value, .TxtOfficeID.Value, 10)

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

The data returned into ResultSet of type 'ArrayofCommand', what options are available to how should I define ResultSet and be able to iterate through the resulting array which may not be of a set size

Thanks for the help




Re: Accessing Web Service using Visual FoxPro 8

CetinBasoz


local ix

for ix = 1 to alen(ResultSet)

luElement = ResultSet[m.ix]

*...

endfor

Or you can iterate as a collection:

for each luElement in ResultSet

*...

endfor