2

在过去的几天里,我一直在设置流媒体服务,每次我回到任务时,我都会遇到同样的 400 错误请求。我在这里和网上搜索了许多帖子,这似乎是一个常见问题,但每种情况都不同。下面是我的绑定设置的当前状态 - 我觉得这必须是我忽略的一些小东西。

来自 WCF 分析器的信息:

  • 调用服务时,会引发警告,说明“未找到配置评估上下文”。
  • 下一个条目指出“未找到匹配的服务标签。添加了默认端点。”

这使我相信我设置的任何内容都没有应用于服务,因此抛出错误请求错误,因为它使用了我的流超过的 ~64kb 默认值。

      <!-- 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

我认为您的问题的原因之一是您使用<client>服务器端的部分配置端点,而实际上您应该使用<services>部分来配置您的服务端点。请在此处查看流式传输的服务器配置文件示例http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/streaming-in-wcf/

非常小心你的配置文件,这是 WCF 中出现大多数问题的地方

于 2012-12-19T16:35:45.947 回答
0

对于未来的读者。

我得到“没有找到匹配的标签。添加了默认端点。”

我的xml很好。(在我花了一个小时试图找到格式错误的 xml 之后)。

对我来说,问题是我更改了具体服务类的命名空间。

关键是这个。

在 .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 可能无法识别该元素。元素中“名称”属性的值必须是服务类的完全限定名称 - 因为您使用 IIS 来托管服务,所以它需要与 @ 中的“服务”属性值相同.svc 文件中的 ServiceHost 标记。

于 2016-12-21T21:03:27.767 回答