Soap... UnauthorizedAccessException

inzo21

Regular
Joined
Nov 5, 2003
Messages
74
Hello All,

I'm trying to call a webmethod that accepts three parameters - a filename, a dirname, and an array of byte. The goal is to create the directory passed and transfer the file from client to server. Pretty straightforward.

I'm testing on a WinXP Pro box with IIS 6. When I run my test module however, I get an error dealing with insuffucient access to write to the directory. However, the directory does get created - it just hangs when it tries to create the file and write the bytes to it.

I have tried setting the code access permissions for the .Net framework (i.e. Admin tools - .Net Configuration - Machine - Local Intranet Zene and set the Permission set to full access and the membership condition to all code. Still the same error.

Specifically, I get this error:

An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in system.web.services.dll

Additional information: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.UnauthorizedAccessException: Access to the path "testing" is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.Directory.InternalCreateDirectory(String fullPath, String path)
at System.IO.Directory.CreateDirectory(String path)
at BTFileTransferApps.Service1.SaveThisFile(String filename, String dirname, Byte[] bytearray) in C:\Inetpub\wwwroot\BTFileTransferApps\FileWorks.asmx.vb:line 69
--- End of inner exception stack trace ---

my web service call looks like this:


<WebMethod()> _
Public Sub SaveThisFile(ByVal filename As String, ByVal dirname As String, ByVal bytearray As Byte())

Debug.WriteLine("process started from web...file: " & filename)

Dim ds As Directory

If ds.Exists(dirname) Then
Debug.WriteLine("Dir Exists")

Else
ds.CreateDirectory(dirname)
Debug.WriteLine("Directory Created!")
End If

Dim fullpath As String = "c:\servertest" & "\" & dirname & "\" & filename
Debug.WriteLine("web - dir name: " & dirname)
Debug.WriteLine("web - file name: " & filename)
Debug.WriteLine("web - full name: " & fullpath)


Debug.WriteLine("Attempting to save file!")
Dim fsInput As FileStream = New FileStream(fullpath, FileMode.Create, FileAccess.Write)
fsInput.SetLength(0)
fsInput.Write(bytearray, 0, bytearray.Length)
fsInput.Close()

Debug.WriteLine("File created from Byte Array")


End Sub

anyone have any ideas.

thanx,

inzo
 
getting there

Hey pDamp - I tried that. Thanks though. I've narrowed it down to the inability for it to create the directory. When I pulled out the following piece of code and hardcoded a directory to write the byte array to, it worked fine.

Dim ds As Directory

If ds.Exists(dirname) Then
Debug.WriteLine("Dir Exists")

Else
ds.CreateDirectory(dirname)
Debug.WriteLine("Directory Created!")
End If

still stuck on this.

inzo
 
Got It!

I love Microsoft!!! ;-)

The issue seemed to be instantiating a directory object. When I isolated this with another web service, it had a hard time with the constructo - stating it was deemed private. I did some searching and found that I needed to call the operation outright. Thus, I replaced the directory check with the follwing code:

If Not (Directory.Exists(fulldirpath)) Then
Directory.CreateDirectory(fulldirpath)
End If

Dim fullpath As String = fulldirpath & "\" & filename

works fine now. Thanks for the interest though Pdamp. You seem to always be around.

inzo
 
Back
Top