WCF The request failed with HTTP status 405: Method Not Allowed

霸气de小男生 提交于 2019-12-07 01:19:53

问题


I have a WCF service that has been hosted on a Windows Service and uses the BasicHttp endpoint to serve Windows Mobile devices that has been connected to it.

The problem is that with the Device Emulator. I can connect to the service and using it without any problems, but with an actual device. I receive the error:

WCF The request failed with HTTP status 405: Method Not Allowed.

I have used following code to implement the service.

BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
basicHttpBinding.UseDefaultWebProxy = false;

m_ServiceHost.AddServiceEndpoint(typeof(IKooft), basicHttpBinding, "KooftService");
m_ServiceHost.Open();

How can I solve this problem?


回答1:


Check your IIS extensions, particularly those for .wsdl are valid:

In IIS:

  • Look at the properties for your site.
  • In the Home Directory tab, click configuration.
  • Click add (my path is "C:\Program Files (x86)\Common Files\MSSOAP\BINARIES\SOAPIS30.DLL" )
  • Set the extension to .WSDL and allow "Get" and "Post"
  • Select "Script Engine" and "Verify That File Exists"

That should be it.




回答2:


If you are using a WCF REST service, you should define your contract method like this:

[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json)]
string CheckService();

Particularly note that WebInvoke attribute and Method="POST".




回答3:


When using WCF you might also need to map the .svc file type to aspnet_isapi.dll in IIS.



来源:https://stackoverflow.com/questions/368494/wcf-the-request-failed-with-http-status-405-method-not-allowed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!