6

我有以下 WCF :

    [OperationContract]
    IList<OperationRoomDto> GetOperationRooms();

我有一个使用这个 WCF 的网站,当我使用 Visual Studio(Asp.Net 开发服务器)时它工作正常,但是当我将 WCF 部署到 IIS 时,我得到了这个异常:

远程服务器返回错误:(405) Method Not Allowed。

我制作了一个简单的网站来测试这个 WCF(在 IIS 上)并且它有效。

这是网站 web.config 文件的一部分:

  <endpoint address="http://server/WcfService"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMessageService"
            contract="MyProject.Web.Wcf.IMessageService" name="BasicHttpBinding_IMessageService">
  </endpoint>

和这部分网络服务配置文件:

  <system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true" />
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

我试图调试 w3wp.exe 服务以获取任何隐藏的异常,我在 web 服务方法处设置了一个断点,但调试器甚至没有到达那里,并且在到达 web 服务类之前发生了异常。

4

1 回答 1

12

发现问题了,是因为wcf的Url不正确,漏掉了服务文件名

<endpoint address="http://server/WcfService"

它应该变成:

<endpoint address="http://server/WcfService/Service.svc"
于 2012-09-30T07:40:04.413 回答