Results 1 to 7 of 7

Thread: [RESOLVED][02/03] Moving web service issues

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    [RESOLVED][02/03] Moving web service issues

    I now have code working that calls a web service on our development environment. I then rebuilt just that project which had the Web Reference folder within it. I moved the .dll's and also the Web Reference as is and then copied to the production server. I now get, "Not Authorized" errors in production code.

    Any thoughts if there are other settings I have to change or is there a way to resetup the Web Service on the production server?

    There are the files in my Web Reference folder:
    Web References
    - DflImagingService
    - ImagingService.disco
    - ImagingService.wsdl
    - Reference.map

    Thanks in advance.
    Last edited by lleemon; Jan 8th, 2009 at 04:33 AM. Reason: Issue was with the web service calling; it was causing the error.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] Moving web service issues

    I can't understand... when do you get the 'not authorized' error? Is that the exact error? Do you get it when you access the site or when you access the web service?

    If it's when you access the website, then check your IIS settings, ensuring that anonymous or windows authentication is enabled (whatever you're supposed to be using, that is).

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    Re: [02/03] Moving web service issues

    I get it when I access the web service. I know it's erroring is because the following line writes to a log file:
    Log2File("Web Service Error: " & result.Exceptions(i) & " ")

    On my development server where I added the Web Service it doesn't error.

    Code:
    Dim imagingService As DflImagingService.ImagingService = Nothing
                Dim results As DflImagingService.ImageResult() = Nothing
                Dim credentials As DflImagingService.Credentials = Nothing
                Dim fileStream As fileStream = Nothing
                Dim pro As Long = 0
                pro = CType(PRONumber, Long)
                Dim ctr As Integer = 0
    
                Try
                    ' Instantiate the web service objects.
                    imagingService = New DflImagingService.ImagingService()
                    credentials = New DflImagingService.Credentials()
                    ' Set username/password properties of credentials object.
                    credentials.UserName = m_sUsername
                    credentials.Password = m_sPassword
    
                    ' Set the credentials property of the imaging service to your credentials object.
                    imagingService.CredentialsValue = credentials
                    ' Call the TrackByDate() web method.
                    results = imagingService.GetImages(pro)
                   
                    Dim result As DflImagingService.ImageResult
                    For Each result In results
                        If result.Exceptions Is Nothing Then
                            If result.DocumentType = "DELIVERY RECEIPT" Then
                                
                                ' Do something w/ image data.
                                
                                fileStream = New fileStream(DownloadPath, FileMode.Create)
                                fileStream.Write(result.ImageData, 0, result.ImageData.Length)
                                fileStream.Seek(0, SeekOrigin.Begin)
                                fileStream.Close()
                                bReturn = True
                            End If
                        Else
                            Dim i As Integer
                            For i = 0 To result.Exceptions.Length - 1
    
                                Log2File("Web Service Error: " & result.Exceptions(i) & " ")
                               
                            Next
                        End If
                        ctr += 1
                    Next
                Catch soapException As System.Web.Services.Protocols.SoapException
                    Dim webServiceExceptions As WebServiceException() = ParseSoapException(soapException)
    
                    Dim stringBuilder As New stringBuilder()
                    Dim i As Integer
                    For i = 0 To webServiceExceptions.Length - 1
                        stringBuilder.Append(webServiceExceptions(i).Message & vbCr & vbLf)
                    Next
                    Throw New Exception(stringBuilder.ToString())
                Finally
                    If Not (imagingService Is Nothing) Then
                        imagingService.Dispose()
                    End If
                    imagingService = Nothing
                    credentials = Nothing
                    If Not (fileStream Is Nothing) Then
                        fileStream.Close()
                    End If
                    fileStream = Nothing
                End Try

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] Moving web service issues

    So what is the exact error message?

    Based on vague information, you'll probably need to check the security settings on the virtual directory or website hosting the web service. It could be a setting at an IIS level blocking the call or it could be the username and password you are passing through.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    Re: [02/03] Moving web service issues

    The exact errors are:

    Not Authorized
    Not Authorized
    Not Authorized
    Not Authorized
    Not Authorized

    That's it based on the loop.

    I will check the settings. It's not the u/p since I wrote those to the same log and matched the development u/p.

    Do you know what exact setting could cause this?

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    Re: [02/03] Moving web service issues

    Can we change this thread to vb.net?

    I ran a test by just putting this web service code in a new web project and then moved to same production server. Works like a charm.

    So the new question is, using a web service in vb.net different then asp.net? The funny thing is why does it work on my development server.

    Frustrating.

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [02/03] Moving web service issues

    From past experience, here is what I know usually happens:

    You create a web service on your machine which creates a virtual directory on your machine with the default of 'windows authentication' checked.

    Same goes for a web application.

    Now in many cases, even on test servers/production servers, the new virtual directory created for a web service has windows authentication checked.

    When you run an application in debug mode, it runs under your security credentials. So I'm not talking about the username/password in code, I mean the windows domain credentials that you used to log on.

    A windows form application always runs under the security credentials of the current user which is why the web service call from there worked for you.

    At this point, you need to verify if windows authentication is checked in the directory security settings in your virtual directory on the production and test servers. If it is, then you probably don't need it, get rid of it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width