Big fun with web services

VBAHole22

Contributor
Joined
Oct 21, 2003
Messages
432
Location
VA
I have a web service that performs some action on a file. My service exposes two web methods. The first accepts a single file path to work on. The second accepts an array of paths to work on, it then breaks open the array and calls the first method on each in turn.
My question is what is the best way to call this web service from a front end asp.net page? Should I instantiate a single web service object and send the array of paths or should I create the loop to open the array on the client page and call a new web service object for each of the paths?

I'm going to begin testing both methods to see what happens. Here is how I envision it:
PHP:
 'Mode 1
        'Send an array of all the paths to be done
        Dim obj As New TransService.TransService
        obj.Timeout = -1
        Try
            obj.TranslateDrawings(aList)
        Catch ex As Exception
            Me.txtError.Text = "Error Loading Array : " & ex.Message
        End Try


        'Mode 2
        'Break open the array here and send each path to a different web method

        For j = 0 To aList.GetUpperBound(0) - 1
            Dim AnObj As New TransService.TransService
            AnObj.Timeout = -1
            Try
                AnObj.TranslateDrawing(DGNList(j))
            Catch ex As Exception
                Me.txtError.Text = "Error sending single path to service"
            End Try
        Next

Will the code for Mode 2 actually work? Or should I be creating an array of web service objects?
 
This is turning into a major headache. I can't even test the theory to report the results to interested parties.
See my web service accesses network resources, so I had to impersonate, so I turned off anonymous access in IIS, so the calling page can't call a web service that has anonymous turned off.
I got past that by adding the following to the proxy object that calls the web method for the front end:

PHP:
Dim obj As New TransService.TransService
        obj.Credentials = System.Net.CredentialCache.DefaultCredentials()

So the web service calls go through now. Which is nice.
however when the web method runs it can no longer access the network resources!!
Both the service and the front end are impersonating.
The web service can access the network resources when I run it alone, but not when the front end calls it.

Permission issues just piss me off. It's like building a house of cards. You get it set up and someone comes along and bumps the table.
 
I managed to hammer this out. I needed to deny anonymous access on the front end asp.net page.

Impersonating is a combination of the web.config line and shutting off the default anonymous access through IIS. A good way to test what user is on is with the following

PHP:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim username As String = System.Security.Principal.WindowsIdentity.GetCurrent().Name
        Me.txtUser.Text = username
 
maybe...?

I like your handle.

Perhaps you can mount the network resource as a drive to the fileserver that you are trasnferring to and reference it via straight unc or file url?

On the loop question, I noticed that in your loop, you are instantiating a new instance of yuour web service method for each item in your array. You might want to reconstruct the method and call a particular function of a single instance for every service in the ar5ray.

I have a file transfer service that recursively scans directories and transfers files using this method. It's less garbage to clean up and a little more efficient.

just an idea.

inzo
 
Back
Top