我创建了一个RESFTful WCF Web服务,并将其作为新的Web应用程序安装在IIS中。 WCF有一些操作,例如:登录, getEmployees ...等。当我从vs发布并运行它时它工作正常,所以我可以从浏览器链接到达:
http://myserver/service.svc
http://myserver/service.svc?wsdl
http://myserver/Login?user=sample&password=paswd
http://myserver/getEmployees?name=dada
并通过操作链接获取确切所需的数据作为回复。
但是只有当我从vs运行网络服务时它才有效,但是当我尝试从浏览器访问链接并且网络服务没有在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,任何想法是什么是问题吗?我错过了什么吗?
答案 0 :(得分:2)
当IIS上的WCF服务时,将忽略<baseAddresses>
中指定的任何基址,并且基址将是.svc文件的URL。
端点元素中的address
属性是相对地址,可能类似于address="rest"
。
因此,在IIS中,网址将为http://myserver/service.svc/rest/getEmployees?name=dada
<强>更新强>
要删除svc扩展程序,请查看this question