2009年4月22日

[WCF]CommunicationException when invoking Web Service via WCF Client

I added aweb service as a Service Reference in VS2008, while invoking, a CommunicationException was thrown indicate that WCF could not serialize response message due to XmlNameTable legth exceed maxinum allowed.

CommunicationException can be throw in various scenario. In my case, the exception message has indicate that XmlNameTalbe name has exceed the max length.

We can fix this by modifying app.config.

Open the app.config, find the basicHttpBinding section(since this is a regula web service, it has to be basicHttpBinding). Find related attribute and change the value to an acceptable value. In my case the attribute will be [maxNameTableCharCount]

    <bindings>
<basicHttpBinding>
<binding name="WebService_SIPSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>

沒有留言:

Blog Archive

About Me