1

私は現在、Webサービス(WS1)を呼び出すアプリケーションを持っています。これはWS2上でホストされているサーバーの情報を取得/設定するために別のWebサービス(WS2)を呼び出します。 WS2から直接WS2に呼び出すアプリケーションがあるかのように、WS1からWS2にユーザーの資格情報を渡すことができるようにしたいと思います。これを行う方法はありますか?あるWebサービスから別のWebサービスに資格情報を渡すには?

これは私が現在持っているものです。

アプリケーションコード:

BasicHttpBinding basicHttpBinding = 
    new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly); 

basicHttpBinding.Security.Transport.ClientCredentialType = 
    HttpClientCredentialType.Windows; 

basicHttpBinding.MaxReceivedMessageSize = 131072000; 

AppMgr.AppMgrSoapClient appMgr = 
    new AppMgr.AppMgrSoapClient(
     basicHttpBinding, 
     new EndpointAddress(@"http://SomeServer/Service.asmx")); 

appMgr.ClientCredentials.Windows.AllowedImpersonationLevel = 
    TokenImpersonationLevel.Impersonation; 

appMgr.ChannelFactory.Credentials.Windows.ClientCredential = 
    CredentialCache.DefaultNetworkCredentials; 

appMgr.SomeWebMethodCall(); 

( 'SomeServer' オン)Webサービスの1コード

BasicHttpBinding basicHttpBinding = 
    new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly); 

basicHttpBinding.Security.Transport.ClientCredentialType = 
    HttpClientCredentialType.Windows; 

basicHttpBinding.MaxReceivedMessageSize = 131072000; 

WS2Service.WS2ServiceSoapClient myServiceReference = 
    new WS2Service.WS2ServiceSoapClient(
     basicHttpBinding, 
     new EndpointAddress(@"http://SomeOtherServer/AnotherService.asmx")); 

myServiceReference.ClientCredentials.Windows.AllowedImpersonationLevel = 
    TokenImpersonationLevel.Impersonation; 

myServiceReference.ChannelFactory.Credentials.Windows.ClientCredential = 
    CredentialCache.DefaultNetworkCredentials; 

そのWebサービスでの最後の行コードを変更する必要がある、私はそれを知っている...しかし、私はそれを設定するか分からない... ClientCredentials.UserNameがありますが、私はこのレベルでパスワードを持っていません。

+0

"C#.NET 3.0"のようなものをタイトルに追加するのではなく、タグを使用してください。 –

+0

私はWCFのセキュリティについてよく分かりませんが、あなたの問題は 'AllowedImpersonationLevel'にあると思います。私は 'TokenImpersonationLevel.Delegation'で試してみるhttp://msdn.microsoft.com/en-us/library/system.security.principal.tokenimpersonationlevel.aspx –

+0

私は委任を試みました、私はまだ始まったWebユーザーを取得していますWS2側のサービス: – Tizz

答えて

-3

私はC#でコードを作成しませんが、Webサービスコールを使用して資格情報を投稿するのが望ましいと思われます。

そのためには、HTTP要求の本文に資格情報を追加する必要があります。

+3

5分-2スコア。私はあなたがやりたいことではないと推測しています。 – Tizz

関連する問題