3

これは私を夢中にさせています。ASP.NET Web フォーム経由で WCF サービスにアクセスしようとしています。次のchannelfactoryようにバインドを設定しています。

BasicHttpBinding b = null;

if (Communication.SlServiceURL.StartsWith("https"))
    b = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
else
{
    b = new BasicHttpBinding();
    b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
}

b.MaxBufferSize = 2147483647;
b.MaxReceivedMessageSize = 2147483647;
b.Security.Transport = new HttpTransportSecurity { ClientCredentialType = HttpClientCredentialType.Ntlm, ProxyCredentialType = HttpProxyCredentialType.None };
b.Security.Message = new BasicHttpMessageSecurity { ClientCredentialType = BasicHttpMessageCredentialType.UserName };

次に、次の方法で新しい Channel Wrapper を作成します。

public ClientChannelWrapper(Binding binding, EndpointAddress remoteAddress)
{
    m_Factory = new ChannelFactory<T>(binding, remoteAddress);
}

バインディングとhttps://[myservice]/myservice.svc URL を として渡していますremoteAddress

問題は、IIS 7 を使用して運用サーバーでサービスを呼び出すと、サイトで Windows 認証が有効になり、認証のプロバイダーとして "NTLM" のみが有効になり、他のすべてが無効になります (匿名、フォームなどはありません)。例外:

例外の種類: MessageSecurityException

例外メッセージ: HTTP 要求は、クライアント認証スキーム 'Ntlm' で承認されていません。サーバーから受信した認証ヘッダーは「NTLM」でした。

これはかなり奇妙で、これを回避する方法を見つけることができないようです。私は別の ASP.NET フォームでホストされているSilverlightアプリケーションも持っていますが、同じ IIS サイトでホストされている ASP.NET サイトで同じことが機能しないのはなぜでしょうか。

また奇妙: F5 を使用して Visual Studio からサイトを起動すると、IIS7 マシンで運用 WCF サービスにアクセスするときに機能します。サイトをデプロイするとすぐに例外が発生します。

編集: Silverlightはサービスとクライアント コンピューターを介して直接通信するため、Silverlight がASP.NETとは異なる動作をする理由は明らかです。例外を除いて、まだ運がありません。

4

0 に答える 0