0

WCFWebサービスを使用するアプリケーションがあります。

httpsバインディングを使用するように構成されています。正常に動作します。同じものにHTTPバインディングを追加したかったのです。

私の要件は、クライアントが私のドメイン(またはVPN)にある場合、HTTPバインディングを使用する必要があることです。また、外部クライアントの場合は、HTTPSバインディングを使用してほしい。どうすればそれを行うことができますか?私はWCFを初めて使用しますが、これが初めての試みです。

参照用に構成ファイルを添付しました。HTTPバインディングのエンドポイントをどこに追加するかわかりませんでした。どんな助けでも適用されるでしょう。

<system.serviceModel>
    <services>
      <service name="{service name}"
                behaviorConfiguration="httpsBehavior">
        <!--HTTPS END POINT-->
        <endpoint address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="SecureHTTPBinding"
                  contract="{service contract}" />

    <!--METADATA ENDPOINT--> 
    <endpoint address="mex"
              binding="mexHttpsBinding"
              contract="IMetadataExchange" />
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="httpsBehavior">
      <serviceMetadata httpsGetEnabled="true" httpsGetUrl="" />
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>

    <behavior name="httpBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>

  </serviceBehaviors>
</behaviors>

<bindings>
  <basicHttpBinding>
    <!--HTTPS BINDING-->
    <binding name="SecureHTTPBinding">
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>

    <!--HTTP BINDING-->
    <binding name="BasicHttpBinding">
      <security mode="None" />
    </binding>

  </basicHttpBinding>
</bindings>

編集:netTCPバインディングの追加

<system.serviceModel>
    <services>
      <service name="{Service Name}"
                behaviorConfiguration="httpsBehavior">
        <!--HTTPS END POINT-->
        <endpoint address="https://localhost/Service1.svc"
                  binding="basicHttpBinding"
                  bindingConfiguration="SecureHTTPBinding"
                  contract="{Service Contract}"  name="httpsEndPoint"/>

    <!--METADATA ENDPOINT--> 
    <endpoint address="mex"
              binding="mexHttpsBinding"
              contract="IMetadataExchange" />

    <!--HTTP END POINT-->
    <endpoint address="http://localhost/Service1.svc"
              binding="basicHttpBinding"
              bindingConfiguration="HttpBinding"
              contract="{Service Contract}" name="httpsEndPoint"/>

    <!--TCP METATADATA END POINT-->
    <endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:808/Service1.svc" />
      </baseAddresses>
    </host>

    <!--TCP ENDPOIN-->
    <endpoint address="net.tcp://localhost:808/Service1.svc" binding="netTcpBinding" contract="{Service Contract}" name="netTCPEndPoint" />



  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="httpsBehavior">
      <serviceMetadata httpsGetEnabled="true" httpsGetUrl="" />
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>

  </serviceBehaviors>
</behaviors>

<bindings>
  <basicHttpBinding>
    <!--HTTPS BINDING-->
    <binding name="SecureHTTPBinding" allowCookies="true"
             maxReceivedMessageSize="20000000"
             maxBufferSize="20000000"
             maxBufferPoolSize="20000000">
      <readerQuotas maxDepth="32"
             maxArrayLength="200000000"
             maxStringContentLength="200000000"/>

      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>

    <!--HTTP BINDING-->
    <binding name="HttpBinding" allowCookies="true"
             maxReceivedMessageSize="20000000"
             maxBufferSize="20000000"
             maxBufferPoolSize="20000000">
      <readerQuotas maxDepth="32"
             maxArrayLength="200000000"
             maxStringContentLength="200000000"/>
      <security mode="None" />
    </binding>

  </basicHttpBinding>

  <!--TCP BINDING-->
  <netTcpBinding>
    <binding transferMode="Buffered" />
  </netTcpBinding>

</bindings>

私は、コード内の数字に対するDoS攻撃の可能性を認識しており、それを回避します。今のところ、それを機能させたかっただけです。この設定ファイルを使用すると、次のようなエラーが発生します

エンドポイントMetadataExchageTcpBindingのスキームnet.tcpに一致するベースアドレスが見つかりませんでした。登録されているベースアドレスは[http、https]です。

誰かが私のサービスのnet.tcpバインディングを公開するのを手伝ってもらえますか?どんな助けでも適用されます

4

1 に答える 1

1

netTcpBindingドメインクライアントに使用します。ネットワークファイアウォールは、HTTPトラフィックを許可している間、デフォルトで生のTCPトラフィックをほぼ確実にブロックするため、各クライアントが適切なエンドポイントに到達することを自然に保証します。ドメインクライアントのパフォーマンスがさらに向上する可能性があります。

それを望まない場合(たとえば、WCFホストがサポートしていない場合、またはVPNクライアントに問題がある場合)は、場所に関係なく、すべてのクライアントに対して1つのHTTPSエンドポイントを公開するだけです。SSLのコストは、そもそもクロスネットワーク呼び出しを行うオーバーヘッドと比較して取るに足らないものになります。

バックグラウンド:

  • netTcpBindingコンパクトなバイナリ形式でデータを送信します。これは、HTTPを介してXMLテキストを送信するよりも効率的です。欠点は次のとおりです。非.NETクライアントとの互換性がなく、ファイアウォールで特定のポートを開いて通過させる必要があります。ただし、これらの問題はどちらもシナリオにとって問題にはなりません。
  • すべてのエンドポイントがアドレス/バインド/コントラクトの一意の個別の組み合わせを持っている限り、WCFサービスで任意の数のエンドポイントを公開できます。したがって、HTTPSエンドポイントとTCPエンドポイントの両方が異なるアドレスとバインディングを持つため、同じサービスに公開できます。
于 2012-11-28T15:45:40.260 に答える