on 06-04-2014 7:53 PM
Support has hit a lull recently, so I've gotten back to an issue that has me stumped.
I've created a webservice in PB 12.5.2 Classic that has two methods: readFile and writeFile.
The writeFile method just creates a text file with some test text in it. It works fine, the file created in the folder I would expect (namely: C:\inetpub\wwwroot\testwebservice_root\file\session\__webservice__\c )
My issue comes from trying to read from a file in the readFile method. I've put a test INI file in the \file\common\c folder, and when the webservice starts, it is copied to \file\session__webservice__\c as I would expect (so file exists). However, when I try either a ProfileString, or even just a fileOpen, I cannot access the file (fileOpen returns -1). Below is my code, basically following Chris' STD framework in reading from an ini file:
#if defined PBWEBSERVICE then // Web Service?
ls_virtual_path = MapVirtualPath (ls_filename ) // YES=Get its Path
#end if
li_pos = POS (ls_virtual_path, ls_filename) // Got a path?
IF li_pos > 0 THEN // YES=>Get file name
ls_virtual_path = MID (ls_virtual_path, 1, li_pos - 1) // Remove file name
END IF
ls_ini_file = ls_virtual_path
ls_ini_file += ls_filename
// test read here
//ls_result = ProfileString (ls_ini_file, "WebService", "Language", "X")
li_filenum = fileOpen(ls_ini_file)
IF li_filenum < 0 THEN
ls_result = "file open fail"
ELSE
li_len = fileRead(li_filenum, ls_text)
ls_result = "read " + string(li_len) + " bytes."
END IF
fileClose(li_filenum)
The variable ls_ini_file has the correct full path and ini file name as I am expecting. Any suggestions is greatly welcome!
Jim
Hi Jim;
Yes, this is a little trickier that one first thinks. I finally solved it in my latest STD Foundation Classes for IIs Web Service framework for PB Classic. In fact, I will be publishing this new release (v2.0) up on to the SourceForge website later today. My PB frameworks are all free BTW.
Even though this is v2.0 - the WS framework was actually initially written for EAServer in 1998 and then enhanced from there. I only ported the EAS code into an IIs version just over 1 year ago (IIs v1.0). This is the first major upgrade to the WS framework for IIs since the "port" - however, its jam packed with new features.
FYI: The way I resolved the INI file deployment folder to session folder at run-time was to use the MS-Windows Shell API to get the job done. The WS framework in v1.0 supported the WShell feature - so that made the task easier when I got to code the INI file issue in v2.0.
STD Foundation Classes | Free Development software downloads at SourceForge.net
Regards ... Chris
PS: I demonstrated the WS framework at the Charlotte NC PB Conference this past March. I hear Matt is just in the planning stages for next years conference.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jim;
Its uploaded on SF now ... Great White North Technical Evangelist: STD Web Service Framework - Version 2.0 Released!
Regards ... Chris
li_pos = POS (ls_virtual_path, ls_filename) // Got a path?
IF li_pos > 0 THEN // YES=>Get file name
ls_virtual_path = MID (ls_virtual_path, 1, li_pos - 1) // Remove file name
END IF
ls_ini_file = ls_virtual_path
ls_ini_file += ls_filename
// test read here
//ls_result = ProfileString (ls_ini_file, "WebService", "Language", "X")
li_filenum = fileOpen(ls_ini_file)
At first glance, it looks like you are reconstructing the file name from path and name without the '/' or '\'...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.