2010-11-02 42 views
4

我有一個名爲「Palladium」的WCF Web服務,它是作爲VS2008解決方案中的項目創建的。
我有一個名爲「Palladium.svc」的頁面上託管着此服務的ASP.Net Web應用程序。
當我將表單數據發佈到Web服務時,我的服務接收到該數據並可以使用它進行操作。未應用WCF Web服務綁定配置

現在我將圖像發佈到服務,並且帖子大小超出WCF的默認maxReceivedMessageSize屬性屬性。爲了解決這個問題,我在ASP.Net Web應用程序web.config文件中添加了一個綁定配置。

我的問題是綁定配置似乎沒有應用。

該服務正在從iPhone應用程序發佈,並且當帖子大小小於65k時,該服務正常工作。一旦帖子大小超過這個,我得到一個400(錯誤的請求)錯誤。
出於測試目的,我在ASP.Net Web應用程序中創建了一個test.aspx文件,它將一些表單值和圖像發佈到Web服務。同樣,當帖子大小在默認的65k大小下時,服務工作正常。超過65k,我得到了400錯誤。

測試頁的帖子的網址符合以下URITemplate /job-photo/{photoId}/{palladiumId}/{jobId}

如果有人可以幫我調試這個問題,將不勝感激。

標記爲測試頁

 <html xmlns="http://www.w3.org/1999/xhtml" > 
     <head runat="server"> 
      <title></title> 
     </head> 
     <body> 
      <form id="form1" action="http://localhost/cds/resources/services/palladium.svc/job-photo/1/235DE168-5D1C-46A4-89F2-FD17C6B9F415/567" method="post" enctype="multipart/form-data"> 
      <div> 
       <input type="text" name="user" value="joe bloggs" /> 

       <input type="file" name="photo" /> 
       <input type="submit" name="btnsubmit" value="submit" /> 
      </div> 
      </form> 
     </body> 
     </html> 

服務信息從web.config中

 <system.serviceModel> 
     <bindings> 
     <wsHttpBinding> 
      <binding name="large_message_binding" maxBufferPoolSize="5242880" maxReceivedMessageSize="5242880"> 
      <readerQuotas maxStringContentLength="5242880" maxArrayLength="5242880" maxBytesPerRead="5242880" /> 
      </binding> 
     </wsHttpBinding> 
     </bindings> 

     <behaviors> 
     <serviceBehaviors> 
     <behavior name="CDS.UI.Resources.Services.PalladiumBehavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
     </behaviors> 

     <services> 
     <service behaviorConfiguration="CDS.UI.Resources.Services.PalladiumBehavior" 
     name="CDS.UI.Resources.Services.Palladium"> 
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="large_message_binding" contract="CDS.PalladiumService.IPalladium"> 

     <identity> 
      <dns value="localhost" /> 
     </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
     </services> 

    </system.serviceModel> 

標記從Palladium.svc

<%@ ServiceHost Language="C#" Debug="true" Service="CDS.PalladiumService.Palladium" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %> 

回答

4

我的理解是

Service="CDS.PalladiumService.Palladium" 

應引用基礎類型。

如從這裏的name屬性:

<service behaviorConfiguration="CDS.UI.Resources.Services.PalladiumBehavior" 
    name="CDS.UI.Resources.Services.Palladium"> 

如果它們分配給實際類型的基礎服務類的它解決了問題?

+0

感謝您的建議Leigh - 「Palladium」實際上是服務類的類型。該服務工作完全正常,只要郵政規模不超過65k。 – 2010-11-02 04:50:29

+0

嗨尼克,即使您從web.config中刪除服務配置,該服務也能正常工作。我的觀點是,如果兩個元素不相同,我相信配置與服務的匹配不會發生。 – 2010-11-02 07:31:24

+0

感謝Leigh,配置的改變對此有所幫助。進行更改後,配置似乎被服務使用 - 儘管現在我完全得到了完全不同的錯誤。我已經[在這裏創建了一個新問題](http://stackoverflow.com/questions/4083758/wcf-webservicehostfactory-maxreceivedmessagesize-configuration)與我現在收到的問題 - 你可能能夠爲我散發一些光芒! – 2010-11-03 02:31:53