我使用VS2010创建了一个wcf服务,当我从VS2010运行它时,它正常工作,但是当我在IIS 6上部署它时(根据this帖子),它不起作用。
我做了这个步骤:
C:\WCFServices\HRService
)中创建了一个文件夹,并将HRService.svc
和web.config复制到该文件夹,并授予ASPNET
用户对此文件夹的完全访问权限。Bin
文件夹,并将我的服务dll复制到其中。HR
)中创建了新的虚拟目录:
我的.svc
个文件,web.Configs如下:
我的.svc
文件
<%@ ServiceHost Language="C#" Debug="true" Service="HumanResourceService.HRService" %>
我的web.Config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" />
</basicHttpBinding>
</bindings>
<services>
<service name="HumanResourceService.HRService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="" contract="HumanResourceService.IHRService" >
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
但是当我想通过IE访问我的WCF服务时,我收到此错误:
有谁能告诉我,问题是什么?
答案 0 :(得分:1)
确保配置文件中的服务名称与.svc文件匹配。在您发布的代码中,它没有。您的.svc文件具有“HumanResourceService.HRService”,因此<service>
元素的name属性应匹配:
<service name="HumanResourceService.HRService">
此外,这是一个RESTful服务还是SOAP?我问,因为您使用webHttpBinding
作为服务,这是针对REST的。如果不是,我建议basicHttpBinding
或wsHttpBinding
。
如果是REST,则将其添加到配置文件的行为部分:
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
答案 1 :(得分:0)
我发现了问题。
在IIS和 Web服务扩展部分中,ASP.NET V4.0.30319
状态为禁止,我将其更改为允许,问题已解决。