Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Properties Not Exposed?
Message
From
14/11/2001 12:18:39
 
 
To
14/11/2001 11:48:46
General information
Forum:
Visual FoxPro
Category:
Web Services
Miscellaneous
Thread ID:
00581251
Message ID:
00581625
Views:
29
>You lost me a bit here - but it sounds interesting if it allows me to accomplish this. Can you please elaborate?

Ok, I've never done it, but it makes sense in my head.

Here is your first, stateful object, lets say.
DEFINE CLASS firstbizobj AS Session OLEPUBLIC
	firstname = ""
	lastname = ""

	PROCEDURE GetRecord(lnID AS Number) AS Boolean 
		IF SEEK(lnID)
			this.FirstName = mytable.fname
			this.LastName = mytable.lname
		ENDIF 
	RETURN FOUND()

	PROCEDURE SaveRecord() AS Boolean 
		REPLACE fname WITH this.FirstName, lname WITH this.LastName
	RETURN

ENDDEFINE
Now, lets create a stateless wrapper for it:
DEFINE CLASS webservicebizobj AS Session OLEPUBLIC

	oBizObj = .NULL.

	PROCEDURE Init
		this.oBizObj = NEWOBJECT('firstbizobj')
	ENDPROC 

	PROCEDURE GetRecord(lnID AS Number) AS String

		IF this.oBizObj.GetRecord(lnID)
			
			* Create an XML string from the properties in the stateful object
			lcXML = '< name firstname="' + this.FirstName + '" ' + ;
				'lastname="' + this.LastName + '" />'
		ENDIF 
	RETURN lcXML

	PROCEDURE SaveRecord(lcXML AS String) AS Boolean 

		* Parse the XML into and save the record
		this.oBizObj.GetRecord(lnIDfromXML)
		this.oBizObj.FirstName = lcFirstNamefromXML
		this.oBizObj.LastName = lcLastNamefromXML
		this.oBizObj.Save()
	RETURN

ENDDEFINE
Now the above class should be able to be compiled as a web service, and you can actually write a stateful wrapper for that:
DEFINE CLASS secondbizobj AS Session OLEPUBLIC
	firstname = ""
	lastname = ""
	oWebService

	PROCEDURE Init
		this.oWebService = CREATEOBJECT('webservicebizobj') && create the webservice here with the soap client
	ENDPROC 

	PROCEDURE GetRecord(lnID AS Number) AS Boolean 
	
		lcXML = this.oWebService.GetRecord(lnID)
		this.FirstName = lcFirstNamefromXML
		this.LastName = lcLastNamefromXML

	RETURN

	PROCEDURE SaveRecord() AS Boolean 
	
		lcXML = '< name firstname="' + this.FirstName + '" ' + ;
			'lastname="' + this.LastName + '" />'
		this.oWebService.SaveRecord(lcXML)
	
	RETURN

ENDDEFINE
Looks like it can be done. I recommend actually creating stateless web services, and using them as stateless objects, but I suppose this doesn't hurt.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform