Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to set initial XML default virtual directory
Message
De
05/04/2004 07:57:37
 
 
À
02/04/2004 15:54:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Web Services
Divers
Thread ID:
00891869
Message ID:
00892212
Vues:
19
I have done this. I recently wrote article for the VFUG newsletter. I don't think VFUG will mind me posting it here. Here is a portion of it.


For me, the road to web server based data access began when I saw the AVI of FoxPro 7.0 on the VFP web page. If you saw it, it was the part where the crystal report was automatically updated over the web. Perfect! At last they were doing what I wanted to do and I ran out and bought the upgrade. I began to try to figure out what they were doing. No where in the documentation could I find a hint of where the server should reside. All the demos used ‘local host’ on the C: drive of the client. That didn’t make sense to me. I figured that if it was a server/dll it should be on the server. Right? Yet all examples, including some demonstration videos that I bought, showed the local host as the place for the server. Well, the other day I got fed up and uninstalled fox on my client machine, walked over to my server, installed my copy of FoxPro (now version 8.0 SP1) and created a virtual folder/directory. I dumped a table into my web site folder. Then I entered and compiled the code for a simple server.

This is on the server and is published with the task pane

Define Class SHOWPREP As Session OlePublic && SHOWPREP is just a table name <<<<<<<
Procedure TodaysPrep As String
Local loXMLAdapter As Xmladapter
Local lcXMLshowprep As String

loXMLAdapter = Createobject("XMLAdapter")

Use c:\YourWebSiteURL\TableName Shared && This Is Drive C: on the server

* Use SQL to get what you want from the table on the server and put it in a cursor. In this case, data that corresponds to the date

Select * From TableName Where Day(Date()) = Day(prepdate) And Month(Date()) = ; Month(prepdate) Into Cursor tempprep

loXMLAdapter.AddTableSchema("tempprep")
loXMLAdapter.UTF8Encoded = .T.
loXMLAdapter.ToXML("lcXMLshowprep")

Close Tables
Return lcXMLshowprep
Endproc
Enddefine

I found the basic code in the foxpro help file and modified it to work for me on my tables. Using SQL it extracted text from a memo field into a cursor. The CursorToXML command converted the text to XML. I compiled the prg into a multithreaded dll. And saved it in a folder named ‘WebServices’. Then I started the task pane and published the web service. I uninstalled FoxPro and crossed the room to my client machine installed FoxPro and got it running. After opening my client project, I started the toolbox and selected ‘My XML Web Services’. I clicked register and set it to my web site address. Bingo. I had a connection and it appeared on the toolbox ‘My XML Web Service’. I then created a new prg and dragged the new web service to the new prg. In an instant a page of code appeared. There was a remark in it too. It said: “ * Call your XML Web service here. ex: leResult = loSHOWPREP.SomeMethod() “

Note that Intellisense will prompt you with the SomeMethod() as soon as you begin to work on that line.

Along with the generated code, this is compiled in the client application. I just call it with a ‘do’


I added a few lines of code:

WAIT WINDOW " Getting your data " AT 18,43 nowait

Local lcXML, lcAlias as String
Local loXMLAdapter as XMLadapter

lcXML = loShowPrep.todaysprep && This is the primary bit of code needed and FoxPro
* Intellisense will prompt you with the most probable code.

loXMLAdapter = CREATEOBJECT("XMLAdapter")
loXMLAdapter.LoadXML(lcXML)

lcAlias = loXMLAdapter.tables.item(1).Alias
loXMLAdapter.tables.item(1).ToCursor()

SELECT(lcAlias)

I ran the code and it worked. It sucked specific data off the web server and right into my client application where I converted it for viewing in an edit box.

I sincerely hope this little article shortens the learning curve towards creating a multiuser client/web server application of your own.

I am presently trying to reverse the action. I want my users to be able to append a blank and write some text to the blank memo field on the server from the client. I would be delighted to see some examples of how this is done. My email address is foxunc@telus.net

Grady McCue VFP
I ain't skeert of nuttin eh?
Yikes! What was that?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform