Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Web Services for the common VFP Developer
Message
De
26/03/2002 15:12:37
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Web Services
Titre:
Web Services for the common VFP Developer
Divers
Thread ID:
00637482
Message ID:
00637482
Vues:
64
In the article "Web Services for the common VFP Developer" (UT Mag, December 4, 2001) there is an example of a web service used to transfer files between a client and the server.
The FileService class has 2 methods: GetFile() to transfer a file from the server to the client and a SaveFile() method which lets the client save a file on the server.

The relevant code from the article is at the end of this message.

The code does not work as is but needs to be modifed:
1) RETURN FILETOSTR(cFileName) needs to be replaced by RETURN CREATEBINARY(FILETOSTR(cFileName))
2) The WSDL file needs to be edited so that the datatype of the respond type of GetFile() is 'base64Binary' rather than 'string' and the datatype of the cFileStr parameter of SaveFile() is also 'base64Binary' and not 'string'.

When I call these methods from a client which uses the web service:
- GetFile() works fine even with 3 MB files.
- SaveFile() works fine with 30 KB files but fails with 100KB or more files.


Does anyone undestand why SaveFile() does not work with the larger files?

Here is the relevant code from the article
DEFINE CLASS BaseCom AS Session
	PROCEDURE Init
		SYS(2335 ,0) && Turn unattended mode on
	ENDPROC

	PROCEDURE Error(nError, cMethod, nLine)
		LOCAL lcMessage AS String
		lcMessage = 'Error: ' + TRANSFORM(nError) + ' - ' + MESSAGE()
		*
		* If we have an error call COMRETURNERROR this will raise an error on SOAP 
		* that will raise an error on the client.
		*
		COMRETURNERROR(This.Class, lcMessage)
	ENDPROC
ENDDEFINE

DEFINE CLASS FileService AS BaseCom OLEPUBLIC
	FUNCTION GetFile(cFileName AS String) AS String 
		IF FILE(cFileName)
			RETURN FILETOSTR(cFileName)
		ELSE
			COMRETURNERROR('FileService', 'File ' + cFileName + " doesn't exist")
		ENDIF
	ENDFUNC

	FUNCTION SaveFile(cFileName AS String, cFileStr AS String, lOverwrite AS Boolean) AS Boolean 
		
		IF !FILE(cFileName) OR lOverwrite
			STRTOFILE(cFileStr, cFileName)
			RETURN FILE(cFileName)
		ELSE
			COMRETURNERROR('FileService', 'File ' + cFileName + ' already exist')
		ENDIF
	ENDFUNC
	*
	* This lines are only taken in considuration 
	* if this is called over COM and not over SOAP.
	* for SOAP calls all the parameters must be pass 
	*
	DIMENSION SaveFile_COMATTRIB[5]
	SaveFile_COMATTRIB[3] = 'SaveFile' && Proper capitalization
	SaveFile_COMATTRIB[5] = 2 && Specifie the number of required parameters
ENDDEFINE
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform