1

WCF サービス wsHttpBinding をホストしました。次に、クライアント アプリケーションとして WCF サービスにアクセスするための Windows フォーム アプリケーションを作成しました。認証情報はデフォルトで次のように定義されているため、クライアント アプリケーションはローカル マシンで WCF サービスを呼び出すことができます。

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

しかし、同じネットワーク上の別の PC で同じアプリケーションを実行しようとすると、WINDOWS クレデンシャル タイプを使用しているため、認証に失敗します。では、ネットワークまたはインターネット経由で 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>
4

1 に答える 1

1

サービス構成にサービスエンドポイントIDを追加する必要があります。

<endpoint address="" binding="wsHttpBinding" contract="MyWCFService.ICenService">
    <identity>
        <dns value="(server name)" />
    </identity>
</endpoint>
于 2012-09-07T09:13:19.573 に答える