簡體   English   中英

如何使用wsHttpBinding連接到WCF服務

[英]How to connect to a WCF service with wsHttpBinding

我已經托管了WCF服務wsHttpBinding。 然后,我創建了一個Windows窗體應用程序,以作為客戶端應用程序訪問WCF服務。 客戶端應用程序可以在本地計算機中調用WCF服務,因為憑據由defualt定義如下。

<transport clientCredentialType="Windows" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="Windows" negotiateServiceCredential="true"
                    algorithmSuite="Default" />

但是,當我嘗試在同一網絡上的不同PC上運行同一應用程序時,由於使用WINDOWS憑據類型,因此將導致身份驗證失敗。 那么,如何通過netowrk或Internet使用wsHttpBinding對其他客戶端PC進行身份驗證? 我必須使用證書或自定義安全令牌,如何使用?

這是我的WCF服務的web.config

    <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>

您需要在服務配置中添加服務端點標識:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM