WCF 请求失败,HTTP 状态为 405:方法不允许

发布于 2024-07-10 12:52:55 字数 502 浏览 7 评论 0原文

我有一个 WCF 服务,该服务托管在 Windows 服务上,并使用 BasicHttp 端点为已连接到它的 Windows Mobile 设备提供服务。

问题出在设备模拟器上。 我可以连接到该服务并使用它,没有任何问题,但使用的是实际设备。 我收到错误:

WCF 请求失败,HTTP 状态为 405:方法不允许。

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

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

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

我怎么解决这个问题?

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?

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

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

发布评论

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

评论(3

情痴 2024-07-17 12:52:55

检查您的 IIS 扩展,尤其是 .wsdl 的扩展是否有效:

在 IIS 中:

  • 查看站点的属性。
  • 在主目录选项卡中,单击
    配置。
  • 点击添加(我的路径是
    “C:\Program Files (x86)\Common
    Files\MSSOAP\BINARIES\SOAPIS30.DLL" )
  • 将扩展名设置为 .WSDL 并允许
    “获取”和“发布”
  • 选择“脚本”
    引擎”和“验证文件存在”

应该就是这样。

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.

花辞树 2024-07-17 12:52:55

如果您使用的是 WCF REST 服务,您应该像这样定义您的契约方法:

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

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

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

街角卖回忆 2024-07-17 12:52:55

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

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

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