如何解决HTTP状态405“方法不允许” 调用 Web 服务时

发布于 2024-07-06 22:47:04 字数 656 浏览 9 评论 0原文

我遇到了一个问题,我需要访问具有 WSE 2.0 安全性的 SOAP Web 服务。 我已经获得了所有生成的 c# 代理(源自 Microsoft.Web.Services2.WebServicesClientProtocol),我正在应用证书,但是当我调用方法时,我收到错误:

System.Net.WebException : The request failed with HTTP status 405: Method Not Allowed.
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

我已经做了一些谷歌搜索,看起来这是服务器配置问题。 然而,这个网络服务被许多客户端使用,没有任何问题(该网络服务是由新西兰电信提供的,所以它一定配置正确。我相信它是用Java编写的)

任何人都可以解释这个问题吗?

I've got a siluation where i need to access a SOAP web service with WSE 2.0 security. I've got all the generated c# proxies (which are derived from Microsoft.Web.Services2.WebServicesClientProtocol), i'm applying the certificate but when i call a method i get an error:

System.Net.WebException : The request failed with HTTP status 405: Method Not Allowed.
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

I've done some googling and it appears that this is a server configuration issue.
However this web service is used many clients without any problem (the web service is provided by a Telecom New Zealand, so it's bound to be configured correctly. I believe it's written in Java)

Can anyone shed some light on this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

孤星 2024-07-13 22:47:04

好的,找到问题所在了。 我试图调用 .wsdl url 而不是 .asmx url。
哎哟!

Ok, found what the problem was. I was trying to call a .wsdl url instead of .asmx url.
Doh!

云淡月浅 2024-07-13 22:47:04

我发现这是由于 IIS 上未安装 WCF。 最主要的是 .svc 扩展名必须在 IIS 中映射 请参阅此处的 MSDN。 使用 ServiceModelReg 工具完成安装。 每当您获得新计算机或重新安装 IIS 时,您总是需要验证 WCF 是否已安装以及 .svc 是否已映射到 IIS 中。

I found this was due to WCF not being installed on IIS. The main thing is that the .svc extension has to be mapped in IIS See MSDN here. Use the ServiceModelReg tool to complete the installation. You'll always want to verify that WCF is installed and .svc is mapped in IIS anytime you get a new machine or reinstall IIS.

一指流沙 2024-07-13 22:47:04

我遇到了同样的问题,但细节不同:

我们使用的 Url 没有文件 (.asmx) 部分。 在浏览器中调用Url就OK了。 它还可以在通过 Visual Studio 设置 URL 的简单客户端中运行。
但动态设置 Url 不起作用! 它给出了相同的 405 错误。

最后我们发现将文件部分添加到Web Service Url中解决了问题。
也许是 .Net 框架错误?

I had the same problem, but the details were different:

The Url we were using didn't have the file (.asmx) part. Calling the Url in a browser was OK. It also worked in a simple client setting the URL through Visual Studio.
But it didn't worked setting the Url dynamically! It gave the same 405 error.

Finally we found that adding the file part to the Web Service Url solved the problem.
Maybe a .Net framework bug?

一桥轻雨一伞开 2024-07-13 22:47:04

您需要启用 HTTP 激活

转到控制面板 > Windows 功能 > .NET Framework 4.5 高级服务> WCF服务> HTTP 激活

You needto enable HTTP Activation

Go to Control Panel > Windows Features > .NET Framework 4.5 Advanced Services > WCF Services > HTTP Activation

眸中客 2024-07-13 22:47:04

嗯,其他客户端也使用 C#/.NET 吗?

方法不允许 --> 这可以是 REST 服务,而不是 SOAP Web 服务吗?

hmm are those other clients also using C#/.NET?

Method not allowed --> could this be a REST service, instead of a SOAP web service?

尾戒 2024-07-13 22:47:04

MethodNotAllowed相当于 HTTP 状态 405。MethodNotAllowed 指示所请求的资源不允许使用请求方法(POST 或 GET)。

问题在于您的 enpoint uri 不完整或不正确 wcf - .scv 地址
检查您的 proxy.enpoint 或 wcf client.enpoint uri 是否正确。

MethodNotAllowedEquivalent to HTTP status 405. MethodNotAllowed indicates that the request method (POST or GET) is not allowed on the requested resource.

The problem is in your enpoint uri is not full or correct addres to wcf - .scv
Check your proxy.enpoint or wcf client.enpoint uri is correct.

强辩 2024-07-13 22:47:04

就我而言,问题是应用程序配置的形成/调用不正确:
在配置中,服务 url 使用“localhost”作为域名,但实际主机名与我调用的 URL 不同:(所以我将配置中的“localhost”更改为我在 URL 中使用的域名。仅此而已!

In my case the problem was that the app config was incorrectly formed/called:
in config the service url was using "localhost" as domain name, but real hostname differed from the URL I called :( so I changed the "localhost" in config to domainname thah I use in URL. That`s all!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文