2009-07-15 93 views
2

我有很長的XML文件,該文件的內容都低於:FaultException在WCF中發送大量數據?

<?xml version="1.0" encoding="utf-8"?> 
<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Header> 
     <a:Action s:mustUnderstand="1">http://example.org/person</a:Action> 
    </s:Header> 
    <s:Body> 
     <OrderDataBDO xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.datacontract.org/2004/07/BasWare.OM.BusinessDataObjects"> 
      <selected i:type="x:boolean" xmlns="">false</selected> 
      <isSaved i:type="x:boolean" xmlns="">false</isSaved> 
      <metadata i:nil="true" xmlns=""/> 
      <hasUnsavedValues i:type="x:boolean" xmlns="">false</hasUnsavedValues> 
      <hasChanged i:type="x:boolean" xmlns="">false</hasChanged> 
      <defaultResourceId i:type="x:string" xmlns="">BWRc.OM.BUSINESSOBJECTS.ORDERDATABDO.ORDER_DATA</defaultResourceId> 
      <_x0031_ xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:ADate" xmlns=""> 
       <_x0031_ i:type="x:boolean">false</_x0031_> 
       <_x0032_ i:type="x:boolean">false</_x0032_> 
       <_x0033_ i:type="x:boolean">false</_x0033_> 
       <_x0034_ i:nil="true"/> 
       <_x0035_ i:type="x:boolean">true</_x0035_> 
       <_x0036_ i:type="x:dateTime">1753-01-01T12:00:00</_x0036_> 
       <_x0037_ i:type="x:string">d</_x0037_> 
       <_x0038_ i:type="x:string">ActualDeliveryDate</_x0038_> 
      </_x0031_> 
      <_x0032_ xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:AString" xmlns=""> 
       <_x0031_ i:type="x:boolean">false</_x0031_> 
       <_x0032_ i:type="x:boolean">false</_x0032_> 
       <_x0033_ i:type="x:boolean">false</_x0033_> 
       <_x0034_ i:nil="true"/> 
       <_x0035_ i:type="x:boolean">true</_x0035_> 
       <_x0036_ i:type="x:string"/> 
       <_x0037_ i:nil="true"/> 
       <_x0038_ i:type="x:string">BuyerCode</_x0038_> 
      </_x0032_> 
      <_x0033_ xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:AID" xmlns=""> 
       <_x0031_ i:type="x:boolean">false</_x0031_> 
       <_x0032_ i:type="x:boolean">false</_x0032_> 
       <_x0033_ i:type="x:boolean">false</_x0033_> 
       <_x0034_ i:nil="true"/> 
       <_x0035_ i:type="x:boolean">true</_x0035_> 
       <_x0036_ i:type="x:string"/> 
       <_x0037_ i:nil="true"/> 
       <_x0038_ i:type="x:string">BuyerId</_x0038_> 
      </_x0033_> 
      <!--etc--> 
      <_x0034_6 xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:AMoney" xmlns=""> 
       <_x0031_ i:type="x:boolean">false</_x0031_> 
       <_x0032_ i:type="x:boolean">false</_x0032_> 
       <_x0033_ i:type="x:boolean">false</_x0033_> 
       <_x0034_ i:nil="true"/> 
       <_x0035_ i:type="x:boolean">true</_x0035_> 
       <_x0036_ i:type="x:decimal">0</_x0036_> 
       <_x0037_ i:type="x:string">N2</_x0037_> 
       <_x0038_ i:type="x:string">TaxSum</_x0038_> 
      </_x0034_6> 
      <_x0034_7 xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:AString" xmlns=""> 
       <_x0031_ i:type="x:boolean">false</_x0031_> 
       <_x0032_ i:type="x:boolean">false</_x0032_> 
       <_x0033_ i:type="x:boolean">false</_x0033_> 
       <_x0034_ i:nil="true"/> 
       <_x0035_ i:type="x:boolean">true</_x0035_> 
       <_x0036_ i:type="x:string"/> 
       <_x0037_ i:nil="true"/> 
       <_x0038_ i:type="x:string">Text1</_x0038_> 
      </_x0034_7> 
      <_x0034_8 xmlns:d4p1="http://schemas.datacontract.org/2004/07/BasWare.ProductFramework.BDOFramework" i:type="d4p1:AString" xmlns=""> 
       <_x0031_ i:type="x:boolean">false</_x0031_> 
       <_x0032_ i:type="x:boolean">false</_x0032_> 
       <_x0033_ i:type="x:boolean">false</_x0033_> 
      </_x0034_8> 
     </OrderDataBDO> 
    </s:Body> 
</s:Envelope> 
+0

爲什麼你認爲有必要發佈整個消息? – 2009-07-15 16:46:39

+0

那麼,有什麼問題?請發佈完整的例外。 – 2009-07-16 02:48:55

+0

感謝John,John可以使用一個方法創建一個示例wcf應用程序,該方法接受一個字符串參數並將其打印出來。 然後從客戶端請通過上面我發佈的XML,並調用服務的方法,你會看到這個異常,也許會有更多的關於我的概率的想法。請嘗試。 – 2009-07-16 04:43:16

回答

2

您需要設置各種設置 - 玩弄值,看看哪些工作。

首先,使用你正在使用的任何綁定,並調整<readerQuotas>(maxStringContentLength,maxArrayLength,maxNameTableCharCount) - 如果可以的話,很好!

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="LargeMessages"> 
      <readerQuotas maxDepth="32" 
      maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" 
      maxBytesPerRead="4096" 
      maxNameTableCharCount="2147483647" /> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    </system.serviceModel> 

如果不解決您的問題,您需要創建自己的自定義配置中綁定,並設置了消息級別的限制,以及 - 這樣的事情:

<system.serviceModel> 
    <bindings> 
     <customBinding> 
     <binding name="ExtraLargeMessages"> 
      <textMessageEncoding> 
      <readerQuotas maxDepth="32" 
       maxStringContentLength="2147483647" 
       maxArrayLength="2147483647" 
       maxBytesPerRead="4096" 
       maxNameTableCharCount="2147483647" /> 
      </textMessageEncoding> 
      <httpsTransport 
       maxBufferPoolSize="1048576" 
       maxReceivedMessageSize="1048576" 
       maxBufferSize="1048576"/> 
     </binding> 
     </customBinding> 
    </bindings> 
    </system.serviceModel> 

希望這有助於。

馬克

UPDATE:
我就打算進軍添加這種行爲您服務,然後再調用該方法。

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="DetailedDebug" > 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service name="yourService" behaviorConfiguration="DetailedDebug"> 
     ..... 
     </service> 
    </services> 
    </system.serviceModel> 

你現在應該得到你的客戶詳細的異常信息 - 你能告訴我們它是什麼嗎?也許這是完全不同的東西.......

馬克

0

也許是對象的數量:嘗試添加這樣的事情

<serviceBehaviors> 
    <behavior name="PutTheNameOfYourBehaviorHere"> 
     <dataContractSerializer maxItemsInObjectGraph="10000000" /> 
    </behavior> 
    </serviceBehaviors> 

到您的配置文件。