TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
spgilmore
NA
591
0
Access to the local filesystem from WebService App
Dec 12 2003 12:20 PM
I know this is a long message (my messages always seem to be :), but the question is simple. Thanks in advance to any help! I have a web service that I'm working on. It's just a junker that I'm playing with to make sure that everything I need to do can be done. Once I figure it all out, I'm going to build a new one and copy / paste / rewrite the pertinent parts. My problem is that I cannot read or write files on the local C:\ drive (or any other drive). I have a function that unzips a file to a directory, another function that loads 10 tif files, builds a PDF file and writes the PDF file to disk. BOTH OF THESE WERE WORKING earlier in the day. Now they're NOT WORKING. I get this exception error (I'm using BORLAND client tools, which transforms the exception class type to ERemotableException, so that part is normal): --------------------------- Debugger Exception Notification --------------------------- Project Project1.exe raised exception class ERemotableException with message 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.UnauthorizedAccessException: Access to the path "c:\delme.txt" is denied. ... ... I want anonymous access to this webservice. I have set the anonymous user in IIS (windows 2003, IIS 6) to the administrator account. I have done this time and time again for other web services in Delphi. I know how to do it. The problem with both the ZIP and PDF functions was the same. When debugging, the error occurs when I open a stream to a file. I wanted to make sure of this, so I made two new functions. One opens a file for READING, one opens a file for WRITING. The READING function makes sure that the file exists. If not, it throws an exception to tell me so. Both of these functions throw the same exception as the UNZIP and PDF functions. [WebMethod] public void readfile(string afilename) { if (!File.Exists(afilename)) { throw new Exception("File not found"); } else { FileStream fs = new FileStream( afilename, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite); } } [WebMethod] public void writefile(string afilename) { FileStream fs = new FileStream( afilename, System.IO.FileMode.CreateNew, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite); } Now the part that throws me off. I have various test scripts that I know work. I have an asptest.asp, cgitest.exe, cgitest2.exe, isapitest.dll, isapitest2.dll and soaptest.dll. ALL of these work. cgitest2.exe and isapitest2.dll get their output HTML contents from a local file IN THE SAME DIRECTORY AS THE readfile() FUNCTION LISTED ABOVE. They both work. I edit the file, refresh the browser and the browser output changes accordingly. This tells me that the problem is inside my WebService project. So, I tried 2 other Delphi SOAP servers which use local files and both worked. To figure out if it was Just that project or if it was C# / Visual studio, I tried another bare-bones C# webservice with just the read and write functions above. They throw the aforementioned exception. So I conclude that my problem is bound to C#, Visual studio or the .NET platform. There's something I don't know about security in web services. So my questions are what do I need to change to make my C# webservices capable of reading and writing my local filesystem, and what changed to cause it to stop?
Reply
Answers (
0
)
Help!! Calling a different web site from a web service
Making a webservice for an existing application