Web服务“HTTP状态401” - > “HTTP状态404”问题 [英] Web Service "HTTP Status 401" -> "HTTP Status 404" issue

查看:111
本文介绍了Web服务“HTTP状态401” - > “HTTP状态404”问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在用这个撞墙撞墙几天,所以我希望有人有一些想法。我有一个我创建的Web服务,由.NET类库调用(后者又被另一个应用程序调用)。这在我的开发环境中运行良好。


测试环境:Windows Server 2003,ASP 6.0,.NET 2.0,启用匿名身份验证。所有组件(Web服务,DLL和调用应用程序)都在同一台服务器上。


我首先收到错误请求失败,HTTP状态401:未经授权。经过一些研究,我补充说......


<身份验证模式=" Windows" />

< identity impersonate =" true" />


...到web服务的web.config文件和...


iService.PreAuthenticate = true;

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


...调用Web服务之前的类库代码。 />

进行更改后,现在我收到错误请求失败并显示HTTP状态404:。 (冒号后没有细节)


Web服务在浏览器中工作正常,只有在通过类库调用时才会返回此错误。我尝试了一些东西......


- 删除虚拟目录并重新创建它

- 授予IUSR和ASPNET帐户管理员权限虚拟目录

- 将此代码添加到Web服务的web.config文件中......


< defaultProxy>

< proxy usesystemdefault =" false" />

< / defaultProxy>


- 在Web服务调用之前将此代码添加到类库中...

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

iService.Proxy = proxyObject;


这些更改都没有解决问题,我仍然得到同样的错误。 (注意:在同一个类库中,我正在调用另一个驻留在不同服务器上的其他Web服务,这些调用是成功的。)

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.)

推荐答案

嗯。是你的webproxy正确解析自定义端口吗?

无论这个类库被调用哪里都有一个准确的testserver记录(甚至任何人在这台计算机上监听?检查以确保服务器绑定到外面端口而不仅仅是本地主机?)


Wierd错误。你可以调试它吗?
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?


一切都在同一台计算机上,所以看到服务或代理不应该是一个问题。我将尝试添加一堆事件记录语句来试图看看发生了什么,只是希望有人在经历这些努力之前已经看到了类似的东西。感谢您的评论。如果/当我解决问题以防其他人遇到同样的事情,我会回复。
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.


嗨JJw92,


可以你请说明你的意思:
Hi JJw92,

Could you please clarify what you mean by this:

Web服务在浏览器中工作正常,只有在通过类库调用时才会返回此错误。我试过了几件事...
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...



你看过微软支持提供的文章 HTTP错误404和IIS 6


-Frinny

Have you seen the article supplied by Microsoft Support on HTTP Error 404 and IIS 6?

-Frinny


这篇关于Web服务“HTTP状态401” - &GT; “HTTP状态404”问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆