【发布时间】:2017-12-26 06:44:14
【问题描述】:
我创建了一个 RESFTful WCF Web 服务,并将它作为一个新的 Web 应用程序安装在 IIS 中。 WCF 有一些操作,例如:Login、getEmployees ...等。当我从 vs 发布和运行它时它工作正常,所以我可以从浏览器链接访问,例如:
http://myserver/service.svc
http://myserver/service.svc?wsdl
http://myserver/Login?user=sample&password=paswd
http://myserver/getEmployees?name=dada
通过操作链接,我得到了所需的确切数据作为响应。
但是,它仅在我从 vs 运行 Web 服务时才有效,但是当我尝试从浏览器访问链接并且 Web 服务未在 VS 中运行时,我只能访问如下链接:
http://myserver/service.svc
http://myserver/service.svc?wsdl
但不是操作链接,例如:
http://myserver/Login?user=sample&password=paswd
http://myserver/getEmployees?name=dada
端点配置:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings/>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="AXPAYROLL.PayrollActions" behaviorConfiguration="serviceBehavior">
<endpoint address="http://myserver/" behaviorConfiguration="RESTFriendly" binding="webHttpBinding" contract="AXPAYROLL.IPayrollActions">
<identity>
<dns value="myserver" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://myserver/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RESTFriendly">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="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" />
<serviceAuthorization serviceAuthorizationManagerType="AXPAYROLL.DataContractLayer.DistributorValidator, AXPAYROLL" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我还创建了一个控制台主机应用程序,其中一切正常,就像从 vs 一样,所以 IIS 中的问题肯定可能出在权限上...
我是 WCF 的新手,但我相信它不是正确的运行方式,而不是始终部署 wcf!我还想在没有安装 vs 的生产服务器上安装 wcf,我知道可以使用控制台应用程序实现自托管,但这又不是我想要的,我希望它在正常的 iis 上运行,知道什么是问题吗?我错过了什么吗?
【问题讨论】:
标签: asp.net wcf wcf-data-services wcf-rest