[英]How to solve HTTP status 405 “Method Not Allowed” when calling Web Services
I've got a siluation where i need to access a SOAP web service with WSE 2.0 security. 我需要访问具有WSE 2.0安全性的SOAP Web服务。 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: 我已经获得了所有生成的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)
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) 然而,这个Web服务使用很多客户端没有任何问题(Web服务由新西兰电信提供,所以它必须正确配置。我相信它是用Java编写的)
Can anyone shed some light on this issue? 任何人都可以对这个问题有所了解吗?
Ok, found what the problem was. 好的,发现问题所在。 I was trying to call a .wsdl url instead of .asmx url. 我试图调用.wsdl网址而不是.asmx网址。 Doh! 卫生署!
I had the same problem, but the details were different: 我有同样的问题,但细节不同:
The Url we were using didn't have the file (.asmx) part. 我们使用的Url没有文件(.asmx)部分。 Calling the Url in a browser was OK. 在浏览器中调用Url就可以了。 It also worked in a simple client setting the URL through Visual Studio. 它也适用于通过Visual Studio设置URL的简单客户端。 But it didn't worked setting the Url dynamically! 但它没有动态设置Url! It gave the same 405 error. 它给出了相同的405错误。
Finally we found that adding the file part to the Web Service Url solved the problem. 最后,我们发现将文件部分添加到Web Service Url解决了这个问题。 Maybe a .Net framework bug? 也许是一个.Net框架错误?
I found this was due to WCF not being installed on IIS. 我发现这是因为WCF没有安装在IIS上。 The main thing is that the .svc extension has to be mapped in IIS See MSDN here. 主要的是必须在IIS中映射.svc扩展名。请参阅此处的MSDN。 Use the ServiceModelReg tool to complete the installation. 使用ServiceModelReg工具完成安装。 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. 您总是希望验证是否已安装WCF,并且只要您获得新计算机或重新安装IIS,就会在IIS中映射.svc。
hmm are those other clients also using C#/.NET? 嗯那些其他客户也使用C#/ .NET?
Method not allowed --> could this be a REST service, instead of a SOAP web service? 方法不允许 - >这可能是REST服务,而不是SOAP Web服务吗?
在我的情况下,问题是app配置错误地形成/调用:在配置中服务URL使用“localhost”作为域名,但真正的主机名与我调用的URL不同:(所以我在配置中更改了“localhost”到域名thah我在URL中使用。这就是全部!
You needto enable HTTP Activation 您需要启用HTTP激活
Go to Control Panel > Windows Features > .NET Framework 4.5 Advanced Services > WCF Services > HTTP Activation 转到“控制面板”>“Windows功能”>“.NET Framework 4.5高级服务”>“WCF服务”>“HTTP激活”
MethodNotAllowedEquivalent to HTTP status 405. MethodNotAllowed indicates that the request method (POST or GET) is not allowed on the requested resource. MethodNotAllowed等效于HTTP状态405. MethodNotAllowed指示在请求的资源上不允许请求方法(POST或GET)。
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. 问题在于你的upoint是不完整或正确的wcf地址 - .scv检查你的proxy.enpoint或wcf client.enpoint uri是否正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.