2

ここ数日間、ストリーミング サービスのセットアップをぐるぐる回っていますが、タスクに戻るたびに、同じ 400 Bad Request の壁にぶつかり続けています。ここやウェブで多くの投稿を検索しましたが、これはよくある問題のようですが、状況はそれぞれ異なります. 以下は私のバインディング設定の現在の状態です - これは私が見落としている小さなものでなければならないと感じています.

WCF プロファイラーからの情報:

  • サービスが呼び出されると、「構成評価コンテキストが見つかりません」という警告がスローされます。
  • 次のエントリには、「一致するサービス タグが見つかりませんでした。デフォルトのエンドポイントが追加されました」と表示されます。

これにより、私が設定したものはすべてサービスに適用されていないと考えられ、したがって、ストリームが超過する ~64kb のデフォルトを使用しているため、Bad Request エラーがスローされます。

      <!-- Services Config -->
        <system.web>
        <httpRuntime maxRequestLength="2097150" executionTimeout="7200"/>
        <compilation debug="true" targetFramework="4.0" />    
        </system.web>
    <system.serviceModel>
    <bindings>
      <basicHttpBinding>        
          <binding name="StreamingService"  maxReceivedMessageSize="2147483647"  maxBufferSize="2147483647" transferMode="Streamed" >
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
            <security mode="None">
            </security>
          </binding>        
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="StreamingService" behaviorConfiguration="StreamingServiceBehavior">
          <endpoint address="http://localhost:50577/StreamingContent.svc"
         binding="basicHttpBinding" bindingConfiguration="StreamingService"
         contract="IStreamingContent" name="BasicHttpBinding_IStreamingContent" />
      </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

       <!-- Web Server Config -->
        <bindings>
        <basicHttpBinding>
  <binding name="BasicHttpBinding_IStreamingContent" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647"
           maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
    </basicHttpBinding>
    </bindings>    
    <client>
        <endpoint address="http://localhost:50577/StreamingService.svc"
             binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IStreamingService"
            contract="StreamingService.IStreamingService" name="BasicHttpBinding_IStreamingService" />
        </client>

新鮮な視点は確かに役立ちます。

編集:以下のアドバイスを受けた後、上記の構成を更新しましたが、プロファイラーで一致するタグが見つからないという同じ問題がまだ発生しています。今じゃないでしょ?

考え?

4

2 に答える 2

3

問題の理由の 1 つは、実際にはセクションを使用してサービス エンドポイントを構成する<client>必要があるのに、サーバー側でセクションを使用してエンドポイントを構成していることだと思います。<services>ここでストリーミング用のサーバー構成ファイルの例を参照してください http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/streaming-in-wcf/

構成ファイルには本当に注意してください。これは、WCF で最も問題が発生する場所です。

于 2012-12-19T16:35:45.947 に答える
0

将来の読者のために。

「一致するタグが見つかりませんでした。デフォルトのエンドポイントが追加されました。」

私のxmlは大丈夫でした。(不正なxmlを見つけるのに1時間費やした後)。

私にとっての問題は、concrete-service クラスの名前空間を変更したことでした。

鍵はこれです。

.svc ファイルには、いくつかのマークアップがあります

<%@ ServiceHost Language="C#" Debug="true" Service="MyCompany.MyNamespace.MyConcreteService" %>

これは、.cs クラスの完全修飾名でなければなりません。

サービス モデル xml にも完全修飾名が必要です。

  <service name="MyCompany.MyNamespace.MyConcreteService"
           behaviorConfiguration="MyServiceBehavior"
           >

        <!-- 
        Whole bunch of other stuff not shown here
        -->

  </service>

上記はクラスを模倣します

namespace MyCompany.MyNamespace
{
    public class MyConcreteService : IMyService
    {
    }
}

正しい完全修飾名があり、.svc ファイルに正しくコピーされ、xml に正しくコピーされていることを確認してください。

私はここから答えを得ました:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/3bb9b3ad-8fc4-40a6-9bb8-fb34f9011d39/bad-request-error-when-uploading-file-to-server?forum=wcf

要素が WCF によって認識されていない可能性があります。要素の「name」属性の値は、サービス クラスの完全修飾名である必要があります。IIS を使用してサービスをホストしているため、@ の「Service」属性と同じ値である必要があります。 .svc ファイルの ServiceHost タグ。

于 2016-12-21T21:03:27.767 に答える