WCF配置部分問題解決

最近寫了一個快遞查詢的服務,在本機測試可以正常運行,部署到服務器上卻出現錯誤,費了不少勁,總算解決 了,現在總結幾條:

1、在網頁上輸入WCF服務地址可以訪問,但在程序裏會提示,解析地址錯誤:

原因是解析時是按服務器的計算機名來解析了,

解決方法:在配置IIS網址時,在“主機頭”:輸入服務器IP地址

2、客戶端使用WCf服務時,提示沒有授權,不以使用服務,

 解決方法:配置里弄增加:
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfig" >
  <bindings>
   <wsHttpBinding>
    <binding name="wsHttpBindingConfig">
     <security mode="None"/>
    </binding>
   </wsHttpBinding>
  </bindings>

3、輸入WCF地址,提示靜態文件

是因爲沒有加處理程序映射:

在web.config中<handlers><handlers>中加入:

<add name="svc-ISAPI-2.0_32bit" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
            <add name="svc-ISAPI-2.0_64bit" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness64" />



發佈了15 篇原創文章 · 獲贊 2 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章