Quantcast
Viewing all articles
Browse latest Browse all 8950

Issue reading file from webservice

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


Viewing all articles
Browse latest Browse all 8950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>