By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,273 Members | 1,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,273 IT Pros & Developers. It's quick & easy.

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

P: 7
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="true" / >

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

iService.PreAuthenticate = true;
iService.Credentials = System.Net.CredentialCache.DefaultCredentials;

... 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 usesystemdefault="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.)
Jul 18 '07 #1
Share this Question
Share on Google+
11 Replies


Plater
Expert 5K+
P: 7,872
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?
Jul 18 '07 #2

P: 7
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.
Jul 19 '07 #3

Frinavale
Expert Mod 5K+
P: 9,731
Hi JJw92,

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...
Have you seen the article supplied by Microsoft Support on HTTP Error 404 and IIS 6?

-Frinny
Jul 19 '07 #4

P: 7
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
Jul 19 '07 #5

P: 7
In debugging the issue, I know that it gets to the iService.CreateTrx() statement that calls the web service and all the parameters have valid values...
Expand|Select|Wrap|Line Numbers
  1. WebSvc.Integrate iService = new WebSvc.Integrate();
  2. iService.PreAuthenticate = true;
  3. iService.Credentials = System.Net.CredentialCache.DefaultCredentials;
  4. IWebProxy proxyObject = new WebProxy("http://localserver:80", true);
  5. iService.Proxy = proxyObject;
  6. 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+Client+ 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+Client+ 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+Client+ 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
Jul 20 '07 #6

P: 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!
Jul 20 '07 #7

Plater
Expert 5K+
P: 7,872
These are the log entries for the failures yes? (I see the 40x error codes)
What do log entries for successful ones look like?

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+Client+ 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+Client+ 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+Client+ Protocol+2.0.50727.42) 404 0 0
Jul 20 '07 #8

P: 7
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;+Windows+NT+5.2;+.NET+CL R+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?
Jul 20 '07 #9

Plater
Expert 5K+
P: 7,872
I would say, based on the log that yes it's trying port 80, it says it in the log.
Expand|Select|Wrap|Line Numbers
  1. 2007-07-20 04:54:49 W3SVC1 127.0.0.1 POST /_vti_bin/owssvr.dll - 80 
  2.  
And, back to my very first point in this thread which was
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.
Jul 20 '07 #10

P: 7
Okay, thanks for the help. I'll check it out.
Jul 20 '07 #11

100+
P: 145
Jim,

Can you post the code which took care of issue(s)?
Sep 22 '09 #12

Post your reply

Sign in to post your reply or Sign up for a free account.