2011-05-13 2 views
2

私は顧客のユーザー名/パスワードバリデーターを持っています。 web.configのendpoints bindingConfiguration属性にそれを入れるだけで十分ですか、それともServiceメソッドで明示的に呼び出す必要がありますか?私はそれをサービスオペレーションと呼んでいないときに呼び出されることに気付きました。私は何か間違っているのですか?web.configエンドポイントBindingConfigurationにカスタムユーザー名バリデーターを置くだけで十分ですか?

これは私が私のバインディングを持っているかのセクションに定義されています。これは私が私のサービスノードが定義されている方法です

<bindings> 
    <wsHttpBinding> 
    <binding name="CustomAuthentication"> 
     <security mode="Message"> 
     <message clientCredentialType="UserName"/> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

<service behaviorConfiguration="CustomValidator" name="Test.TestService"> 

私のエンドポイント属性は、そのBindingConfiguration = "CustomAuthentication"

を持っています

これは、私のServiceBehaviorsの動作を定義したものです:

<behavior name="CustomValidator"> 
     <serviceCredentials> 
     <userNameAuthentication userNamePasswordValidationMode="Custom" 
           customUserNamePasswordValidatorType="Test.CustomUserNameValidator, FuzionSync"/> 

     <serviceCertificate findValue="MyWebSite" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/> 

     </serviceCredentials> 

     <serviceMetadata httpGetEnabled="True"/> 

    </behavior> 

サービスコールを呼び出すためにwcfテストクライアントを実行すると、Validateメソッドも呼び出されません。私がそれを呼び出すための唯一の方法は、明示的に呼び出す操作にそれを置く場合です。

+0

私が正しいとすれば、wcfサービスに接続する前に、これらを信用証明書として使用する必要があります。 – BreakHead

+0

@BreakHead、私はあなたの答えに混乱していますか? – Xaisoft

答えて

3

これは、バインディング構成とサービス動作の両方で指定する必要があります。それが私たちのプロジェクトの1(重要な部分はclientCredentialType="UserName"であり、<serviceCredentials>要素)にどのように見えるかです:

<bindings> 
    <wsHttpBinding> 
    <binding name="SSLWithCustomAuthentication"> 
     <security mode="TransportWithMessageCredential"> 
     <transport clientCredentialType="None" proxyCredentialType="None" /> 
     <message clientCredentialType="UserName" 
       negotiateServiceCredential="true" 
       algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

<behaviors> 
    <serviceBehaviors> 
    <behavior name="customAuthenticationBehavior"> 
     <serviceCredentials> 
     <userNameAuthentication 
      userNamePasswordValidationMode="Custom" 
      customUserNamePasswordValidatorType="Namespace.YourValidator, AssemblyName"/> 
     </serviceCredentials> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

、その後はあなたのサービスの利用behaviorConfiguration="customAuthenticationBehavior"を持っています。

WCFではSSLなしでUserName認証を使用できるとは限りません。

+0

私はどのように持っているかを示すために投稿を更新します。 – Xaisoft

+0

私の投稿を更新します。私はmローカルマシン上に一時的なSSL証明書を持っています。 – Xaisoft

+0

私によく見えます。ところで、クライアントが接続するときにサービス操作自体が呼び出されるのですか、まったく何も起こりませんか? –

関連する問題