1

チャネル ファクトリを使用して WCF クライアントを作成しました。しかし、別のマシンのサーバーに接続できません。(407) Prxy Authentication Required 例外が発生します。

WSHttpBinding wsBinding = new WSHttpBinding();
        wsBinding.BypassProxyOnLocal = true;

        EndpointAddress endpoint =
          new EndpointAddress("http://machineName:7676/MyWCFService");
        ChannelFactory<IService> sericeInterface =
            new ChannelFactory<IService>(wsBinding, endpoint);

        sericeInterface.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
        sericeInterface = sericeInterface.CreateChannel();

これは私のクライアント接続コードニペットです。サービスのメソッドを呼び出すと例外が発生します。

4

1 に答える 1

1

このCodePlexリンクを見て、自分のシナリオにぴったり一致するシナリオを見つけてください。さまざまな状況/バインディングにさまざまな資格情報を設定する方法のチェックリストとサンプルを提供します。

また、このMSDNリンクは、使用していると思われるWindows認証に役立つ場合があります。

クレデンシャルを割り当てるには、MSDNリンクから取得した以下のようなものが必要です。

CalculatorClient cc = new 
    CalculatorClient("WSHttpBinding_ICalculator");
// This code returns the WindowsClientCredential type.            
cc.ClientCredentials.Windows.ClientCredential.UserName = GetUserName();
cc.ClientCredentials.Windows.ClientCredential.Password = GetPassword();
于 2009-12-04T09:57:22.723 に答える