Web Service "HTTP Status 401" -> "HTTP Status 404" issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jjw92
    New Member
    • Jul 2007
    • 7

    Web Service "HTTP Status 401" -> "HTTP Status 404" issue

    I've been banging my head against the wall with this one for a couple days so I'm hoping someone has some ideas. I have a web service that I created that is called by a .NET class library (which in turn is called by another application). This all works fine in my development environment.

    Test environment: Windows Server 2003, ASP 6.0, .NET 2.0, Anonymous authentication is enabled. All components (web service, DLL, and calling application) are all on the same server.

    I first got the error "The request failed with HTTP status 401: Unauthorized." After some research I added...

    < authentication mode="Windows" / >
    < identity impersonate="tr ue" / >

    ... to the web.config file for the web service and ...

    iService.PreAut henticate = true;
    iService.Creden tials = System.Net.Cred entialCache.Def aultCredentials ;

    ... to the class library code before the call to the web service.

    After making that change, now I'm getting the error "The request failed with HTTP status 404: ." (no detail after the colon)

    The web service works fine from the browser, it's only returning this error when called through the class library. I've tried a few things...

    - Removed the virtual directory and recreated it
    - Granted the IUSR and ASPNET accounts administrator priviledges to the virtual directory
    - Added this code to the web.config file for the web service...

    < defaultProxy >
    < proxy usesystemdefaul t="false" / >
    < / defaultProxy >

    - Added this code to the class library before the web service call...

    IWebProxy proxyObject = new WebProxy("http://testserver:8080 ", true);
    iService.Proxy = proxyObject;

    None of those changes resolved the issue, I still get the same error. (Note: From the same class library, I'm calling a couple other web services that reside on a different server and those calls are successful.)
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Hmm. is your webproxy thing parsing the custom port correctly?
    Is wherever this class library being called from have an accurate record for testserver (or even anyone listening on THAT computer? check to make sure server is bound to outside port and not just the localhost?)

    Wierd errors. Can you debug it at all?

    Comment

    • jjw92
      New Member
      • Jul 2007
      • 7

      #3
      Everything is all on the same computer so it shouldn't be an issue with seeing the service or proxy. I'm going to try add a bunch of event logging statements to try to see what's going on, just hoping someone had seen something similar before going through that effort. Thanks for the comments. I'll post back if/when I resolve the issue in case someone else runs into the same thing.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Hi JJw92,

        Could you please clarify what you mean by this:
        Originally posted by jjw92
        The web service works fine from the browser, it's only returning this error when called through the class library. I've tried a few things...
        Have you seen the article supplied by Microsoft Support on HTTP Error 404 and IIS 6?

        -Frinny

        Comment

        • jjw92
          New Member
          • Jul 2007
          • 7

          #5
          Originally posted by Frinavale
          Could you please clarify what you mean by this:
          The web service works fine from the browser, it's only returning this error when called through the class library. I've tried a few things...
          Hi Frinny,

          If I open IE and enter the URL of the .asmx file, I get the Service Description page. I can then click on the web service, enter parameter values, and click Invoke to test it. The service runs and returns a successful return code.

          The web service is called from another server by an application not under my control and that call is also successful. I built a .NET assembly that, among other things, has a procedure to call the above web service and I made that assembly COM visible. I needed to do this because the calling application doesn't support calling web services or .NET assemblies (only COM DLLs).

          I don't believe the issue in the article you linked to applies here since Active Server Pages is allowed, as well as ASP.NET 2.0. (Plus the web service runs successfully from the browser, as described above.)

          Thanks!
          Jim

          Comment

          • jjw92
            New Member
            • Jul 2007
            • 7

            #6
            In debugging the issue, I know that it gets to the iService.Create Trx() statement that calls the web service and all the parameters have valid values...
            Code:
            WebSvc.Integrate iService = new WebSvc.Integrate();
            iService.PreAuthenticate = true;
            iService.Credentials = System.Net.CredentialCache.DefaultCredentials;
            IWebProxy proxyObject = new WebProxy("http://localserver:80", true);
            iService.Proxy = proxyObject;
            bool bReturn = iService.CreateTrx(JobNum, ItemNum, Site, Qty, Update, false))
            I added a logging statement as the first line of the web service and it never reaches that point.

            I don't know if anyone can look at these log entries to determine what's happening but this is from the IIS log (appears to show both 401 and 404 errors)...

            2007-07-20 04:54:49 W3SVC1 127.0.0.1 POST /_vti_bin/owssvr.dll - 80 - 127.0.0.1 Mozilla/4.0+(compatible ;+MSIE+6.0;+MS+ Web+Services+Cl ient+Protocol+2 .0.50727.42) 401 2 2148074254
            2007-07-20 04:54:49 W3SVC1 127.0.0.1 POST /_vti_bin/owssvr.dll - 80 - 127.0.0.1 Mozilla/4.0+(compatible ;+MSIE+6.0;+MS+ Web+Services+Cl ient+Protocol+2 .0.50727.42) 401 1 0
            2007-07-20 04:54:49 W3SVC1 127.0.0.1 POST /_vti_bin/owssvr.dll - 80 ITDEVELOP\jdoe 127.0.0.1 Mozilla/4.0+(compatible ;+MSIE+6.0;+MS+ Web+Services+Cl ient+Protocol+2 .0.50727.42) 404 0 0

            No log entry is created in the web service log.

            Any help would be greatly appreciated.
            Thanks, Jim
            Last edited by Frinavale; Sep 22 '09, 02:36 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

            Comment

            • jjw92
              New Member
              • Jul 2007
              • 7

              #7
              401.2 - Logon failed due to server configuration.
              401.1 - Logon failed.
              404.0 - (None) – File or directory not found.

              The first two of these seem to be standard handshaking "errors" usually followed by 200 when authentication completes. In my case, I'm getting that 404.0 log entry instead of 200.

              Any tips on how to pinpoint the cause of this? As I said earlier, the web service runs fine when run through IE (via the Service Description page).

              Thanks!

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                These are the log entries for the failures yes? (I see the 40x error codes)
                What do log entries for successful ones look like?

                Originally posted by jjw92
                2007-07-20 04:54:49 W3SVC1 127.0.0.1 POST /_vti_bin/owssvr.dll - 80 - 127.0.0.1 Mozilla/4.0+(compatible ;+MSIE+6.0;+MS+ Web+Services+Cl ient+Protocol+2 .0.50727.42) 401 2 2148074254
                2007-07-20 04:54:49 W3SVC1 127.0.0.1 POST /_vti_bin/owssvr.dll - 80 - 127.0.0.1 Mozilla/4.0+(compatible ;+MSIE+6.0;+MS+ Web+Services+Cl ient+Protocol+2 .0.50727.42) 401 1 0
                2007-07-20 04:54:49 W3SVC1 127.0.0.1 POST /_vti_bin/owssvr.dll - 80 ITDEVELOP\jdoe 127.0.0.1 Mozilla/4.0+(compatible ;+MSIE+6.0;+MS+ Web+Services+Cl ient+Protocol+2 .0.50727.42) 404 0 0

                Comment

                • jjw92
                  New Member
                  • Jul 2007
                  • 7

                  #9
                  Yes, that's for a failed attempt. And interestingly, those log errors are appearing in the log directory for the "Default Web Site" not the log directory for my service. When processing a successful call though IE, it doesn't write to the "Default Web Site" log and writes this to the web service log...

                  2007-07-20 12:52:49 W3SVC2131071671 192.168.1.211 POST /WebSvc.asmx/CreateTrx - 8080 - 192.168.1.211 Mozilla/4.0+(compatible ;+MSIE+7.0;+Win dows+NT+5.2;+.N ET+CLR+1.1.4322 ;+.NET+CLR+2.0. 50727) 200 0 0

                  So could it be that the call from the DLL is hitting port 80 even though I'm specifying port 8080?

                  Comment

                  • Plater
                    Recognized Expert Expert
                    • Apr 2007
                    • 7872

                    #10
                    I would say, based on the log that yes it's trying port 80, it says it in the log.
                    Code:
                    2007-07-20 04:54:49 W3SVC1 127.0.0.1 POST /_vti_bin/owssvr.dll - 80
                    And, back to my very first point in this thread which was
                    Originally posted by plater
                    Hmm. is your webproxy thing parsing the custom port correctly?
                    You should go through that DLL really close and find out why it's ignoring the custom port specification.

                    Comment

                    • jjw92
                      New Member
                      • Jul 2007
                      • 7

                      #11
                      Okay, thanks for the help. I'll check it out.

                      Comment

                      • dorandoran
                        New Member
                        • Feb 2007
                        • 145

                        #12
                        Jim,

                        Can you post the code which took care of issue(s)?

                        Comment

                        Working...