WS2007FederationHttpBinding を使用する WCF サービスから生成されたサービス参照を持つ WinForms アプリがあります。以下が機能しない理由がわかりません。
私の WinForms アプリは、BearerKey タイプのトークンを処理するように設定された Thinktecture.IdentityServer を使用する WCF サービスを呼び出しています。
クライアントから有効なアクセス トークンを取得し、次の呼び出しを行います。
private static void CallServiceReference(SecurityToken token)
{
ServiceReference1.ClaimsServiceContractClient svcRef = new ServiceReference1.ClaimsServiceContractClient();
svcRef.ChannelFactory.Credentials.SupportInteractive = false;
svcRef.ChannelFactory.CreateChannelWithIssuedToken(token);
var claims = svcRef.GetClaims();
}
サービス参照用の winforms クライアント app.config は次のとおりです。
<system.serviceModel>
<bindings>
<ws2007FederationHttpBinding>
<binding name="WS2007FederationHttpBinding_ClaimsServiceContract">
<security mode="TransportWithMessageCredential">
<message establishSecurityContext="false" issuedKeyType="BearerKey">
<issuer address="https://identity.MyCo.com/issue/wsfed" binding="ws2007HttpBinding"
bindingConfiguration="https://identity.MyCo.com/issue/wstrust/mixed/username" />
<issuerMetadata address="https://identity.MyCo.com/issue/wstrust/mex" />
<tokenRequestParameters>
<trust:SecondaryParameters xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
<trust:KeyType xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer</trust:KeyType>
<trust:CanonicalizationAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/10/xml-exc-c14n#</trust:CanonicalizationAlgorithm>
<trust:EncryptionAlgorithm xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://www.w3.org/2001/04/xmlenc#aes256-cbc</trust:EncryptionAlgorithm>
</trust:SecondaryParameters>
</tokenRequestParameters>
</message>
</security>
</binding>
</ws2007FederationHttpBinding>
<ws2007HttpBinding>
<binding name="https://identity.MyCo.com/issue/wstrust/mixed/username">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="IssuedToken" establishSecurityContext="false" />
</security>
</binding>
</ws2007HttpBinding>
</bindings>
<client>
<endpoint address="https://roadie/WebTest/service.svc" binding="ws2007FederationHttpBinding"
bindingConfiguration="WS2007FederationHttpBinding_ClaimsServiceContract"
contract="ServiceReference1.ClaimsServiceContract" name="WS2007FederationHttpBinding_ClaimsServiceContract" />
</client>
</system.serviceModel>
サービス呼び出し (svcRef.GetClaims()) を実行しようとすると、次のエラーが発生します。
「セキュリティ トークン発行者のアドレスが指定されていません。ターゲット ' https://identity.MyCo.com/issue/wsfed 'のバインディングで明示的な発行者アドレスを指定する必要があります。または、資格情報でローカル発行者アドレスを構成する必要があります。 ."
このエラーは不完全で紛らわしいですが、設定で発行者が指定されているようです!
最後に、WCF サービスと Identity サービスが有効であることはわかっています。これは、カスタム ChannelFactory を使用してすべて正常に機能し、トークンを適用するのとまったく同じ方法を使用しているためです。
var channel = factory.CreateChannelWithIssuedToken(token);
しかし、私の要件は、生成された ServiceReference を使用することです。:(