基本思路
建立與發(fā)布參考網(wǎng)站托管
在IIS中某一網(wǎng)站己单,選擇添加應用程序
image
訪問服務uri:
http://localhost/wcfAppTest/Service1.svc
wcfAppTest/Service1.svc 別名+.svc
訪問具體的服務
http://localhost/wcfAppTest/Service1.svc/service/GetData/23
/service/GetData/23 endpoint中的address/方法名/參數(shù)
比網(wǎng)站托管多了一個wcfAppTest
配置文件參考
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="NewBinding0" />
</webHttpBinding>
</bindings>
<services>
<service name="WcfService4.Service1">
<endpoint address="/service" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="" contract="WcfService4.IService1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 為避免泄漏元數(shù)據(jù)信息讶踪,請在部署前將以下值設置為 false -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<!-- 要接收故障異常詳細信息以進行調(diào)試,請將以下值設置為 true昂秃。在部署前設置為 false 以避免泄漏異常信息 -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<!--<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>-->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!--
若要在調(diào)試過程中瀏覽 Web 應用程序根目錄爆惧,請將下面的值設置為 True屑那。
在部署之前將該值設置為 False 可避免泄露 Web 應用程序文件夾信息哈踱。
-->
<directoryBrowse enabled="true" />
<!--以下是IIS托管后自動添加的部分-->
<handlers>
<remove name="ISAPI-dll" />
<add name="test2" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="D:\WcfService4\bin\WcfService4.dll" resourceType="File" preCondition="bitness32" />
<add name="test" path="*.dll" verb="*" modules="IsapiModule" scriptProcessor="D:\WcfService4\bin\WcfService4.dll" resourceType="File" preCondition="bitness32" />
</handlers>
</system.webServer>