2

私はwcfアプリケーションを持っています。ローカル コンピューター (Windows 7 および IIS 7.5) でテストしたところ、動作しました。ただし、開発サーバー (Windows サーバー 2003、IIS 6) に展開した後。次のエラーメッセージが表示されました。

The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.

Server stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory`1 factory)
   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at ICFIR.ProcessXmlMessage(String xmlDocument)
   at CFIRClient.ProcessXmlMessage(String xmlDocument)

Inner Exception:
The remote server returned an error: (401) Unauthorized.
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)

Googleで何時間も検索しましたが、同様の問題がたくさん見つかりましたが、どれも修正できません。ここに私のweb.configがあります

<basicHttpBinding>
    <binding name="ServiceSoap" 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="65536" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
    </binding>
</basicHttpBinding>
4

2 に答える 2

1

これはBravo11が話していたことです....これはしばらくの間本当に気になりましたが、上記のさまざまな方法を試した後、最終的に解決策に出くわしました。vs2010 でサービスを作成するときに Windows をセキュリティとして追加する場合は、認証モードを Windows に設定する必要があります。

<system.web>
    <compilation debug="true" targetFramework="4.0" />
    <authentication mode="Windows" />
</system.web>

これは、サービスの Web.config または IIS 6.0 のプロパティ -> ASP.NET -> 構成の編集 -> 認証 -> 認証モード ドロップダウンで行うことができます。

IIS で実行することを選択した場合は、常に実行することを忘れないでください。そうしないと、再度公開したときにリセットされます。

これが誰かを助けることを願っています。

于 2014-05-28T16:50:05.133 に答える
1

Windows認証を期待していますが、サーバーと同じドメインにいますか? その場合は、次のように Windows 認証を有効にする必要があります。

<security>
  <transport clientCredentialType="Windows" proxyCredentialType="None" />
  <message clientCredentialType="Windows" />
</security>

オンにしたくない場合は、匿名や証明書などの他の認証タイプをオンにすることができます。これを参照してください:

http://msdn.microsoft.com/en-us/library/ms729700.aspx

注: 呼び出しているマシンからプロキシ サーバーが有効になっている場合、このタイプの問題も発生することがあります。その場合は、プロキシをオフにするか、プロキシに認証を提供してください。

于 2013-10-07T20:02:07.983 に答える