2012-12-19 84 views
2

我一直在過去幾天設置Streaming服務,每次回到任務時,我一直打到400 Bad Request的同一堵牆。我在網上搜索了很多帖子,看起來這是一個常見問題,但每種情況都不一樣。以下是我的綁定設置的當前狀態 - 我覺得這應該是我忽略的小事。Streaming WCF - 400 Bad Request

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

任何新鮮的觀點肯定會有所幫助。

編輯:我更新了配置上述考慮以下的建議後,但我仍然得到在探查同樣的問題在沒有匹配的標籤被發現,只是這一次我相信設置是否正確?顯然不是因爲它現在可以工作不會吧,呃?

想法?

回答

3

我認爲您的問題的原因之一是您在服務器端使用<client>部分配置端點,實際上您應該使用<services>部分來配置您的服務端點。請參閱流在這裏http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/streaming-in-wcf/

非常小心你的配置文件,這是大多數問題都在WCF

+0

嘆了口氣,我認爲這讓我朝着正確的方向前進。在客戶端設置它似乎對我來說是錯誤的。將得到這個工作,並讓你知道。提前致謝。 – buildtehawesome

+0

雖然我覺得這是正確的船,但仍有一些東西。 – buildtehawesome

0

對於未來的讀者服務器配置文件中的一個例子。

我得到了「找不到匹配的標籤,添加了默認端點。」

我的xml很好。 (我花了一個小時試圖找到格式不正確的XML)。

我的問題是我改變了我的具體服務類的命名空間。

關鍵是這個。

在.svc文件,還有一些標記

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

這有可能成爲的.cs類的完全合格的名稱。

AND

您的服務模型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標籤。