2

RESTful サービスを作成し、認証を実装しました。ユーザー名とパスワードを受け入れ、要求されたサービスへのアクセスを許可します。それは正常に動作します。ここで、サービスの上で SSL を使用したいと考えています。このために、証明書を作成し、IIS で必要な設定を行いました。しかし、私のサービスは機能していません。私は webHttpBinding を使用しています。

サービス側の私の Web.Config は次のとおりです。

 <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
    <service  behaviorConfiguration="ServiceBehavior" name="TestAPI">
      <host>
        <baseAddresses>
          <add baseAddress="https://localhost/AuthWithSSLTest/API/TestAPI.svc" />
        </baseAddresses>
      </host>
    <endpoint address="" behaviorConfiguration="RESTFriendly" bindingConfiguration="MywebHttpBinding"  binding="webHttpBinding" contract="ITestAPI" >
      </endpoint>
      <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
  </service>
</services>
<client /><bindings>
  <webHttpBinding>
    <binding name="MywebHttpBinding">
      <security mode="Transport" >
       <transport clientCredentialType="Certificate"/>
      </security> 
    </binding>
  </webHttpBinding>     
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior name="RESTFriendly">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceCredentials>
        <clientCertificate>
          <authentication revocationMode="NoCheck" />
        </clientCertificate>
        <serviceCertificate findValue="CN=tempCertClient" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>

そして、クライアント側のapp.configには

<system.serviceModel>
    <behaviors>
        <endpointBehaviors>
            <behavior name="NewBehavior">
                <clientCredentials>
                    <clientCertificate findValue="CN=tempCertClient" storeLocation="LocalMachine" />
                    <serviceCertificate>
                        <authentication certificateValidationMode="PeerTrust" revocationMode="NoCheck" />
                    </serviceCertificate>
                </clientCredentials>
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <bindings>
        <customBinding>
            <binding name="WebHttpBinding_ITestAPI">

              <httpTransport/>
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="https://localhost/AuthWithSSLTest/API/API.svc/TestMethod"
            behaviorConfiguration="NewBehavior" binding="customBinding"
            bindingConfiguration="WebHttpBinding_ITestAPI"
            contract="TestAPI.ITestAPI" name="WebHttpBinding_ITestAPI" />
    </client>
</system.serviceModel>

クライアントを実行しようとすると、提供された URI スキーム Https が無効です、http が必要と表示されます。

また、VS2008 から Web サービスを呼び出そうとすると、「WebHttpBinding をバインドするエンドポイントのスキーム https に一致するベース アドレスが見つかりませんでした。登録されているベース アドレス スキームは [http] です。」と表示されます。

IIS から Web サービスを実行しようとすると、「バインディング WebHttpBinding を持つエンドポイントのスキーム http に一致するベース アドレスが見つかりませんでした。登録されたベース アドレス スキームは [https] です。」と表示されます。

私はグーグルを試し、提案されたすべてのことを試しましたが、うまくいきませんでした。助けてください。

前もって感謝します, タラ・シン

4

1 に答える 1

1

クライアント構成で、次のように変更してみてください。

<httpTransport/>

に:

<httpsTransport/>
于 2009-11-11T19:31:56.560 に答える