The Artima Developer Community
Sponsored Link

.NET Buzz Forum
WCF MaxStringContentLength and Config

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jonathan Crossland

Posts: 630
Nickname: jonathanc
Registered: Feb, 2004

Jonathan Crossland is a software architect for Lucid Ocean Ltd
WCF MaxStringContentLength and Config Posted: Jan 9, 2009 4:56 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Jonathan Crossland.
Original Post: WCF MaxStringContentLength and Config
Feed Title: Jonathan Crossland Weblog
Feed URL: http://www.jonathancrossland.com/syndication.axd
Feed Description: Design, Frameworks, Patterns and Idioms
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Jonathan Crossland
Latest Posts From Jonathan Crossland Weblog

Advertisement
The data I am sending through the service is very large and very soon, I got the following exception message: "... There was an error deserializing the object of type MyType. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. .."

By default when using Visual Studio and WCF, your app.config will be injected with some servicemodel settings
Using XMLSerializer on a Type received from my wsdl, I get the error, however, I am not passing it through to the server, just client side serialization, I get the same error.



WCF injects xml configuration into your app.config as below.
[code:xml]

<system.serviceModel>
<services>
<service behaviorConfiguration="PublishingService.ProductServiceBehavior"
name="PublishingService.PublishingService">
<endpoint address="" binding="wsHttpBinding" contract="OxiNet.Publishing.ITarget" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
............cut short

[/code]


But it did not contain a vital attribute on the endpoint. "bindingConfiguration="WSHttpBinding_ITarget"

[code:xml]

<system.serviceModel>
<services>
<service behaviorConfiguration="PublishingService.ProductServiceBehavior"
name="PublishingService.PublishingService">
<endpoint address="" binding="wsHttpBinding" contract="OxiNet.Publishing.ITarget" bindingConfiguration="WSHttpBinding_ITarget> bindingConfiguration="WSHttpBinding_ITarget"
<identity>
<dns value="localhost" />
</identity>
</endpoint>
............cut short

[/code]


AND it also required a bindings node, of which I am not sure how much of it, it actually uses. My service fails if its not present.

[code:xml]

<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ITarget">
<readerQuotas maxStringContentLength="2147483647"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="PublishingService.ProductServiceBehavior" ..... cut short


[/code]


then your client can utilize a config or code way of dealing with the size.

[code:xml]

<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ITarget" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize=" 2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4012" maxNameTableCharCount="8192" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
</configuration>

[/code]


or within code you can get a "Max" version of the XmlDictionaryReaderQuotas configuration.

[code:c#]
EndpointAddress endPoint = new EndpointAddress("http://localhost:8731/ProductService");
WSHttpBinding binding = new WSHttpBinding();
XmlDictionaryReaderQuotas readerQuotas = XmlDictionaryReaderQuotas.Max;
binding.ReaderQuotas = readerQuotas;

PublishingService.TargetClient target = new PublishingService.TargetClient(binding,endPoint);
[/code]

Read: WCF MaxStringContentLength and Config

Topic: Michelin Restaurant Guide 2009 - Metropolregion Previous Topic   Next Topic Topic: Windows 7 Beta - Ab 9.1.2009 sind 2,5 Millionen Exemplare zu haben!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use