3

HTTP (HTTPS ではなく) で消費される Web サービスを作成し、NTLM/Windows 認証を使用しようとしています。残念ながら、その「完璧な」組み合わせは見つからないようです。何を試しても、Windows 認証を使用すると、常に HTTPS を使用するように強制されます。また、HTTP を使用すると、Windows 認証のすべての試行が無視されるようです。

これまでの app.config は次のとおりです。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="wsSoap" 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="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://xyz/xyz/xyzws.asmx" binding="basicHttpBinding"
            bindingConfiguration="xyzwsSoap" contract="xyzws.xyzwsSoap"
            name="xyzwsSoap" />
    </client>
</system.serviceModel>
</configuration>

また、basicHttpBinding の代わりに wsHttpBinding を使用して新しいバインディングを作成しようとしましたが、それもうまくいきませんでした。誰かが私たちを正しい方向に向けることができますか?

4

2 に答える 2

1

Windows認証の場合、セキュリティモードを次のように設定する必要がありますTransportCredentialOnly

<security mode="TransportCredentialOnly">
    <transport clientCredentialType="Windows"/>
</security>

また、サーバーとクライアントの構成が同期していることを確認してください。

于 2012-11-21T18:22:11.213 に答える
0

Web.config のサーバー アプリケーション (サービスをホストするアプリケーション) で、system.serviceModel/behaviors/serviceBehaviors新しい動作を作成する必要があります。

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="internalBehaviour">
      <serviceAuthenticationManager authenticationSchemes="Ntlm"/>
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

次に、同じセクション<system.serviceModel>で作成します<bindings>

<bindings>
  <basicHttpBinding>
    <binding name="internal" >
        <security mode="TransportCredentialOnly">
          <transport clientCredentialType="Ntlm"/>
        </security>
    </binding>
  </basicHttpBinding>
</bindings>

次に、同じセクション (公開しようとしているサービスを構成している場所)<system.serviceModel><services>

<services>
       <service behaviorConfiguration="internalBehaviour" name="Corp.WebServices.CorePricingService">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="internal" name="ConveyancingEndpoint" contract="Corp.Core.Interfaces.ICorePricingService" />
  </service>

(明らかに契約変更)

IIS Express次に、Visual Studio (または IIS)から実行している場合は、applicationhost.config

Win7 の場合:
IISExpress C:\Users\[username]\Documents\IISExpress\config
IIS%WINDIR%\System32\inetsrv\config\applicationHost.config

あなたのウェブサイトの<authentication>セクション<windowsAuthentication enabled="true">を見つけるfalse<!--<add value="Negotiate" />-->

<authentication>
            <anonymousAuthentication enabled="false" />
            <basicAuthentication enabled="false" />
            <clientCertificateMappingAuthentication enabled="false" />
            <digestAuthentication enabled="false" />
            <iisClientCertificateMappingAuthentication enabled="false">
            </iisClientCertificateMappingAuthentication>
            <windowsAuthentication enabled="true">
                <providers>
                    <!--<add value="Negotiate" />-->
                <add value="NTLM" />
                 </providers>
            </windowsAuthentication>
        </authentication>

次に、Web.config のクライアント アプリで

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="ConveyancingEndpoint">
      <security mode="TransportCredentialOnly" >
        <transport clientCredentialType="Ntlm"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="http://localhost:53769/CorePricingService.svc" binding="basicHttpBinding" bindingConfiguration="ConveyancingEndpoint" contract="ServiceReference2.ICorePricingService" name="ConveyancingEndpoint"> 
  </endpoint>
</client>

ローカル マシンで Windows 認証を設定する必要がある場合があります。

これで時間が節約できることを願っています。

于 2015-06-22T10:38:36.690 に答える