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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using ASP/HTML page to get XML data from fox database

Status
Not open for further replies.

wmorris

Programmer
May 24, 2002
5
US
Hello all,

I am trying to find a good way to retrive XML web service data from a server. I have a Web service working that connects to a Foxpro database. I can get XML data from Foxpro and other methods, but my goal is to have ASP pages that I can build a small app with that ties directly to the foxpro database.

My XML Service is as follows
GetUnitData (Main Service name in the XML)
FindBookNo (method to retrive info on a release number)

I would like to use the XML FindBookNo and pass a parameter like 'TEST' The Xml will return all info that contains 'TEST' The querry code is in the XML Web Service, I can do this from Foxpro and other types of apps now, works great.

I am trying to create a simple web page that I can ask the user a question and return the data from my XML service.

Sample Format
Enter Release Number:
Click a button here to get XML data back to grid and/or local dataset.
Data results in grid

I sure this is very easy, I just cant seam to find a good example to work with.

Thanks for any help.
 
What version of VFP are you working with? I have no experience with VFP8 yet, but I believe one of it's new features is to create "web services" directly... which I take to mean create OLE-DLL's that can be used directly by ASP without the FOXISAPI.DLL as an intermediary.

Since you're using ASP, you probably can use ANY VFP .DLL containing an OLEPUBLIC class, instantiate an object in the .ASP code in the page, set its properties and call the appropriate method, then use the results of the method.

Do you want to return XML to the client? or is this a web page that will display the results in a web browser? if the latter, then really you don't even need XML, unless you have other objects that you're using through ASP that make processing the XML easy.
 
I am using VFP8, I have written the service in VFP8 and the Web Service is working fine, The problem I have is writting the ASP side, I am a ASP rookie, I do want to return XML data, and place the data in a local dataset. I need to create a small app that can run off the web service. I have been finding other examples and am slowly figuring out the pieces. Any sample ASP code on reading XML data into a local dataset would be great.
This is as far as I got on the vb code, gets stuck on the
lcRetVal = Myservice.FindBookNo("TEST") line, I never get to the response line.

Dim lcRetVal As String
Dim Myservice As New server1.GetUnitData()
lcRetVal = Myservice.FindBookNo("TEST")
Response.Write("The booking data. " & lcRetVal)

This is the working VFP8 web service

DEFINE CLASS GetUnitData AS Session OLEPUBLIC
PROCEDURE FindContNo(contno AS Character) AS String
LOCAL loXMLAdapter AS XMLAdapter
LOCAL lcXMLUnits AS String

mUnitNo=ALLTRIM(contno)+'%'

loXMLAdapter = CREATEOBJECT("XMLAdapter")

USE c:\ds3_320\data\curunits shared
SELECT container,chassis,booking_no ;
FROM curunits ;
WHERE container LIKE mUnitno ;
INTO CURSOR xmlUnits

loXMLAdapter.AddTableSchema("xmlUnits")
loXMLAdapter.UTF8Encoded = .T.
loXMLAdapter.ToXML("lcXMLUnits")

CLOSE DATABASES ALL

RETURN lcXMLUnits
ENDPROC

PROCEDURE FindChasNo(chasno AS Character) AS String
LOCAL loXMLAdapter AS XMLAdapter
LOCAL lcXMLUnits AS String

mUnitNo=ALLTRIM(chasno)+'%'

loXMLAdapter = CREATEOBJECT("XMLAdapter")

USE c:\ds3_320\data\curunits shared
SELECT container,chassis,booking_no ;
FROM curunits ;
WHERE chassis LIKE mUnitno ;
INTO CURSOR xmlUnits

loXMLAdapter.AddTableSchema("xmlUnits")
loXMLAdapter.UTF8Encoded = .T.
loXMLAdapter.ToXML("lcXMLUnits")

CLOSE DATABASES ALL

RETURN lcXMLUnits
ENDPROC

PROCEDURE FindBookNo(bookno AS Character) AS String
LOCAL loXMLAdapter AS XMLAdapter
LOCAL lcXMLUnits AS String

mUnitNo=ALLTRIM(bookno)

loXMLAdapter = CREATEOBJECT("XMLAdapter")

USE c:\ds3_320\data\curunits shared
SELECT container,chassis,booking_no ;
FROM curunits ;
WHERE booking_no = mUnitno ;
INTO CURSOR xmlUnits

loXMLAdapter.AddTableSchema("xmlUnits")
loXMLAdapter.UTF8Encoded = .T.
loXMLAdapter.ToXML("lcXMLUnits")

CLOSE DATABASES ALL

RETURN lcXMLUnits
ENDPROC

ENDDEFINE
 
This is by no means my specialty, but I think the right way to write this in VB is (Strike that... I looked it up in help and there are three ways to create an object in VB... the NEW keyword in a declaration, the Set ... New assignment, and CreateObject()... So this is simply another way to try ):
Code:
Dim lcRetVal As String
Dim Myservice As server1.GetUnitData

Set Myservice = CreateObject('server1.GetUnitData')

lcRetVal = Myservice.FindBookNo("TEST")
Response.Write("The booking data. " & lcRetVal)


Technically, what you created with VFP is not a web service... it is a COM object that will be accessed from an ASP script. The ASP script could be called a web service, particularly if the output were in XML and consumed by a program.

Somehow VFP8 has the ability to create web services in a way different than you are doing (not that you should change... what you are doing is fine). However, just FYI, this method can be used in VFP 6,7 & 8
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top