FaultException在WCF中发送大量数据?
问题描述:
我有很长的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>
答
您需要设置各种设置 - 玩弄值,看看哪些工作。
首先,使用你正在使用的任何绑定,并调整<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>
你现在应该得到你的客户详细的异常信息 - 你能告诉我们它是什么吗?也许这是完全不同的东西.......
马克
答
(接通你的绑定例如,根据)客户端和服务器described here您Max Message Size。
其他可能出错。您可以为WCF使用enable tracing并使用trace log viewer来缩小异常吗?
答
也许是对象的数量:尝试添加这样的事情
<serviceBehaviors>
<behavior name="PutTheNameOfYourBehaviorHere">
<dataContractSerializer maxItemsInObjectGraph="10000000" />
</behavior>
</serviceBehaviors>
到您的配置文件。
为什么你认为有必要发布整个消息? – 2009-07-15 16:46:39
那么,有什么问题?请发布完整的例外。 – 2009-07-16 02:48:55
感谢John,John可以使用一个方法创建一个示例wcf应用程序,该方法接受一个字符串参数并将其打印出来。 然后从客户端请通过上面我发布的XML,并调用服务的方法,你会看到这个异常,也许会有更多的关于我的概率的想法。请尝试。 – 2009-07-16 04:43:16