2008-12-15 256 views
7

我有一个WCF服务托管在Windows服务上,并使用BasicHttp端点为连接到它的Windows Mobile设备提供服务。WCF请求失败,HTTP状态405:方法不允许

问题是用Device Emulator。我可以连接到该服务并且无任何问题地使用它,但是使用实际的设备。我收到错误:

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

我已经使用以下代码来实现该服务。

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

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

我该如何解决这个问题?

回答

4

检查你的IIS扩展,特别是对于那些有的.wsdl有效:

在IIS:

  • 看看你的站点的属性。
  • 在主目录选项卡中,单击 配置。
  • 点击添加(我的路径是 “C:\ Program Files文件(x86)的\共同 文件\ MSSOAP \ BINARIES \ SOAPIS30.DLL”)
  • 将扩展的.wsdl并允许 “获取” 和“邮报”
  • 选择‘脚本 引擎’和‘确认文件是否存在’

这应该是它。

+1

正如我所提到的,它托管在Windows服务应用程序而不是IIS上。 – mrtaikandi 2009-04-04 11:37:51

0

使用WCF时,您可能还需要将.svc文件类型映射到IIS中的aspnet_isapi.dll。

1

如果您使用的是WCF REST服务,你应该定义你的合同方法是这样的:

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

特别注意WebInvoke属性和Method="POST"

相关问题