2012-09-07 37 views
1

我已經託管了WCF服務wsHttpBinding。然後我創建了一個Windows窗體應用程序來作爲客戶端應用程序來訪問WCF服務。客戶端應用程序可以調用本地機器中的WCF服務,因爲證書的定義如下所示。如何使用wsHttpBinding連接到WCF服務

​​

但是當我嘗試運行同一網絡上的不同PC上相同的應用程序,會出現因爲其使用的是Windows憑據類型,認證失敗。 那麼我怎麼能通過netowrk或互聯網與wsHttpBinding認證其他客戶端PC? 我必須使用證書或自定義安全令牌嗎?

這是我的WCF服務

<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="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="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service name="MyWCFService.CenService"> 
     <endpoint address="" binding="wsHttpBinding" contract="MyWCFService.ICenService"/> 
     </service> 
     <!--<service name="CenService.MyService"> 
     <endpoint address="" binding="wsHttpBinding" contract="MyWCFService.IMyService"/> 
     </service>--> 
    </services> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 
+0

您將需要使用證書。 – Bernard

+0

那麼我是新來的WCF 如何使用證書?任何教程? –

+0

在同一網絡上,證書不是必需的。 –

回答

1

您需要添加一個服務端點的身份進入您的服務配置的web.config文件:

<endpoint address="" binding="wsHttpBinding" contract="MyWCFService.ICenService"> 
    <identity> 
     <dns value="(server name)" /> 
    </identity> 
</endpoint> 
相關問題