Currently, only SQL Server is supported as a backend although Visual FoxPro data will work in some situations especially for data retrieval. Automatic INSERT and UPDATE operations however will fail with memo fields that exceed 255 characters of data.
Using wwBusiness with Web Data is very easy once the server side is set up and working. All you have to do is set nDataMode to 4 and either set the cServerUrl to the URL configured for the Web Data Service or call the SetHTTPSQLObject with an already configued wwHTTPSQL object (if you need special HTTP configuration for security, proxy support etc.). AFter that all calls to the business object can proceed the same way as with local data.
oDev = CREATEOBJECT("cDeveloper")
oDev.nDataMode = 4
oDev.cServerUrl = "http://localhost/wconnect/wc.dll?http~HTTPSQL_wwDevRegistry"
*** Create the wwHTTPSQL object - (recommended, but not required if you don't modify the HTTP settings)
oDev.Open()
*** Optional - configure any HTTP settings you need using wwHTTP properties
* oDev.oHTTPSQL.cUsername = "rick"
* oDev.oHTTPSQL.cPassword = "keepguessingbuddy"
* oDev.oHTTPSQL.nConnectTimeout = 40
* oDev.oHTTPSQL.nTransportMode = 2 && Transfer VFP cursors without XML
*** Execute a raw SQL statement against the server
IF odev.Execute("delete wwDevregistry where pk > 220") < 0
? oDev.cErrorMsg
ENDIF
*** Run a query that returns a cursor
lnRecords = oDev.Query("select * from wwDevRegistry where company > 'L' ")
IF oDev.lError
? oDev.cErrorMsg
ELSE
BROWSE
ENDIF
*** Load one object
oDev.Load(8)
? oDev.oData.Company
? oDev.oData.Name
oDev.oData.Company = "West Wind Technologies"
IF !oDev.Save()
? oDev.cErrorMsg
ENDIF
*** Create a new record
? oDev.New()
loData = oDev.oData
loData.Company = "TEST COMPANY"
loData.Name = "Rick Sttrahl"
? oDev.Save()
*** Show added rec
? oDev.Query()
GO BOTT
BROWSERemember this requires that the server url be configured with a wwHTTPSQLServer backend. But on the client side as you can see you can run the same operations that you can run against a business object with local data and expect the same results.
For more info on SQL commands that you can process and how to pass named parameters to the wwHTTPSQL member of wwBusiness see the wwHTTPSQL documentation.
The code to do this is very minimal. Basically you set up an instance of the wwHTTPSQLServer object and configure a couple of options that determine how the request is handled and then pass the XML to the S_Execute() method, which runs the actual SQL command and returns an XML result:
FUNCTION HTTPSQL_wwDevRegistry()
*** Create Data Object and call Server Side Execute method (wrapper for Process Method)
SET PROCEDURE TO wwHTTPSQLServer ADDITIVE
loData = CREATE("wwHTTPSQLServer_Demo")
loData.cConnectString = "server=(local);driver={SQL Server};database=wwDeveloper;pwd=sa;uid=;"
loData.cAllowedCommands = "select,execute,insert,update,delete,method,"
loData.S_Execute(Request.FormXML())
*** Return the output
Response.ContentType = "text/xml"
Response.AddForceReload()
Response.Write( loData.cResponseXML )
ENDFUNC
The above is the minimal code required to set up the server side. Once this URL is configured it can then be accessed via the cServerUrl property in wwBusiness.
There is additional info on how to deal with server side configuration such as authentication and reusing SQL connections available at the How wwHTTPSQLServer works topic.