2009-05-25 24 views
0

WCFコンソールアプリケーションでサービスを使用しようとしています。しかし、私が応答として得るのは、「リモートサーバーが予期しない応答を返しました:(400)Bad Request」です。WCF Windows認証エラー

サービスは、次のオプションで構成されています

<services> 
    <service name="TryOut.BasicService" behaviorConfiguration="NicksBasicBehavior"> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://192.168.10.67:8000/Service" /> 
     </baseAddresses> 
    </host> 

    <endpoint address ="http://192.168.10.67:8000/Service" 

       name="NicksEndpoint" 
       binding="basicHttpBinding" 
       contract="TryOut.IBasicService" 
       bindingConfiguration="BasicBinding" 
       /> 
    </service> 
</services> 

<behaviors> 
    <serviceBehaviors> 
    <behavior name="NicksBasicBehavior">  
     <serviceMetadata httpGetEnabled="true"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

<binding name="BasicBinding"> 
    <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Windows"/> 
    </security> 
</binding> 

私のクライアントの設定ファイルは以下の通りです:

<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding name="NicksEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" 
     receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" 
     bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
     useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Windows" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
<client> 
    <endpoint address="http://192.168.10.67:8000/Service" binding="basicHttpBinding" 
     bindingConfiguration="NicksEndpoint" contract="ServiceReference1.IBasicService" 
     name="NicksEndpoint" /> 
</client> 

私が始めているとき、今、すべてが正常に動作しますサービスと同じPC上のクライアント。私はその後、サーバPCのドメインにないマシン上でクライアントを実行しようとしていた場合、私は情報がクライアントコードでのログインを提供ものの、しかし、私は、エラーを取得:

c.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("Nick", "password", "mydomain"); 

は誰もが持っています私が間違ってやっているアイデア、どうすれば修正できるの?あなたに期待してくれてありがとう!

WCFTestService.Service myService = new WCFTestService.Service(); 
myService.Credentials = System.Net.CredentialCache.DefaultCredentials; 
MessageBox.Show(myService.GetData(123, true)); 
myService.Dispose(); 

あなたはこのコードを使用してmyService.CredentialsにWindows資格情報を渡すためにしようとしてみてくださいでした:

答えて

0

このarticle on MSDNによると、それはあなたが異なった資格情報を指定する必要があるかのように見えますか?それは動作しますか?

マルク・

0

はあなたのクライアントエンドポイント上のアイデンティティ要素でのuserPrincipalNameをspecifing試してみましたか?