WCF Service msg Size Error - wcf

I've two separated module (web based GUI and WCF based Server) and I'm using WCF service reference to access some methods from my GUI to Server. The problem occurs when GUI requests data from Server and it sends huge amount of data to GUI; Maximum Message Size error exception is thrown!
I increased the message size in appropriate section tag in Web.config file and it temporarily worked, but when the data- that is always growing in my case- reaches to the maximum allowed size the error happens again! I know that the bottle neck is on GUI side!
How can I solve the issue and is there any way to make the GUI service reference to handle ever-growing data?
Here is my GUI web.config file:
<pre>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IServerHelper" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="16777216" maxBufferPoolSize="524288" maxReceivedMessageSize="16777216" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" >
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://172.16.16.7:123456/ServerServices" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServerHelper" contract="ServiceReference1.IServerHelper" name="BasicHttpBinding_IServerHelper"/>
</client>
</system.serviceModel>
</pre>
thanks for helping me...

You can set these values up to int.MaxValue. If that's still not enough for your return message, you should try to split your messages. After all, that would be a message of 2GB. Maybe SOAP is not the best way to transport such a beast.

Related

WCF service binding content type mismatch - text/xml and application/soap+xml

I have been at this for a few days trying to figure out why I am getting a content type mismatch error in my binding. There are countless other people that seem to be having this issue but all the resolutions don't apply or haven't worked.
I have looked everywhere trying to figure out why I am getting the following error:
Server Error in '/' Application.
The content type application/soap+xml; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 823 bytes of the response were:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><GetQuoteResponse xmlns="http://soap.service.GMO.com"><Quote_Response><errorMessage></errorMessage><return_List><item><errorMessage></errorMessage><monthlyPremiumAmount>6.0</monthlyPremiumAmount><webID>7P3W4Txst</webID><basePer1>1000.0</basePer1><basePer2>0.0</basePer2><baseRate1>0.05</baseRate1><baseRate2>0.0</baseRate2><benefitID>5365</benefitID><coverageAmount>100000</coverageAmount><grossPer1>1000.0</grossPer1><grossPer2>0.0</grossPer2><grossRate1>0.06</grossRate1><grossRate2>0.0</grossRate2></item></return_List></Quote_Response></GetQuoteResponse></soapenv:Body></soapenv:Envelope>.
The web service I am consuming is not hosted in IIS. The web service itself seems to be working properly because we use SoapUI and get all the proper results returned to us. As you can also see from the above error message, values are being returned from the web service.
I have also been using Fiddler and am able to confirm that the request header content type is text/xml and the response header content type is application/soap+xml.
We have a datalayer where the service reference resides. The app.config looks like this:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="IMSQuoteServiceBinding" 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="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://hostingServerName:81/cgi-bin/jsmdirect?IMSQuote"
binding="basicHttpBinding" bindingConfiguration="IMSQuoteServiceBinding"
contract="Quote.IMSQuoteServicePortType" name="IMSQuoteServicePort" />
</client>
</system.serviceModel>
The web site web.config looks like this:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="IMSQuoteServiceBinding" 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="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://hostingServerName:81/cgi-bin/jsmdirect?IMSQuote"
binding="basicHttpBinding" bindingConfiguration="IMSQuoteServiceBinding"
contract="Quote.IMSQuoteServicePortType" name="IMSQuoteServicePort" />
</client>
Any help would be very much appreciated. I am somewhat new to WCF and am open to any and all ideas.
Thank you all in advance for your help. If you need me to provide any more information, please let me know.
Just as an update.
I changed the service binding from basicHttpBinding to wsHttpBinding. Changing the binding to wsHttpBinding changed the SOAP service to send as a SOAP 1.2 call rather than a SOAP 1.1 call. Once I did this, the content types matched on the send and receive calls which resolved the binding mismatch error.

Sending larger object to WCF results in 400 Bad Request

I have a unit test that sends a moderately large object to a WCF service. If I pass null for that parameter, everything works fine. When I send a populated object, I get an HTTP 400 response.
WCF tracing shows this error:
The maximum message size quota for incoming messages (65536) has been
exceeded.
However, I have cranked up the size configuration parameters in app.config for the unit test project as follows:
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyAppService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="200000000" maxBufferPoolSize="200000000" maxReceivedMessageSize="200000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
What am I missing in my configuration to raise the allowed message size above the 65536 seen in the error message?
UPDATE:
The web.config file for the web service host also sets the maxReceivedMessageSize to a large value (I think):
<binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
If I understand your question correctly, you increased the size for 'maxReceivedMessageSize' in the unit test's app.config. Actually you should make this change in the app.config/web.config of the web service which you are calling from your unit test code. If you host your web service in IIS, then it will be web.config. If you host it in windows service, then you need to make the change in the app.config (which gets moved to your .exe.config file in your bin folder.

Large string argument in WCF operation call

I am unable to pass a string as an argument to a WCF operation call. The string is quite large (about 12000 characters).
I have increased maxStringContentLength in web.config and played around with almost all the attributes but the problem still remains.
I have found a workaround - Split the string at client's end and concatenate at the server's end. It works this way.
Can anybody direct me towards the right way of solving this problem? Why WCF operation call is able to accept the same amount of data (split into 2 string parameters) but throws error when that data is passed in one string parameter? Where do we configure the size limit of WCF operation arguments?
---------------------------------CODE--------------------------------
TestService.Service1Client client = new TestService.Service1Client();
string str = "VERY LARGE STRING";
//DOES NOT WORK
client.TakeLargeStringParam(str);
//WORKS
client.TakeLargeStringParam2(str.Substring(0, 5000), str.Substring(5000));
-----------------------WEB.CONFIG--------------------------
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" 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="819200" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:30701/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="TestService.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
You need to increase the maxStringContentLength at the server side, not at the client. The web.config only has a <client> section, and to configure a service you'd need to set a <service> section there. If there's no matching service configuration on the service, it will use a default one, which has the default quota values.

WCF + net.tcp Communication Timeout problem

I have some critical problem in my project. During transaction time with (wcf + netTCP)
I was getting the exception is.
The communication object,
System.ServiceModel.Channels.ClientFramingDuplexSessionChannel,
cannot be used for communication because it is in the Faulted state.
In WCF service app.config add binding tag with timeout specification. But my transaction has been ended within 10 min. what was the problem..
<bindings>
<basicHttpBinding>
<binding name="ServiceSoap" closeTimeout="0:01:00" openTimeout="0:01:00" receiveTimeout="10:00:00" sendTimeout="10:00: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="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding name="b1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="10:00:00"
transferMode="Buffered"
maxBufferPoolSize="524288"
maxBufferSize="65536"
maxConnections="10"
maxReceivedMessageSize="65536">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
Any one help me !!!..
I'm not sure why you think its a timeout issue? The error message doesn't suggest a timeout has ocured. Could the server be throwing an exception?
I would strongly recommend setting up WCF tracing. Its a bit involved but really worth doing as I've solved many obscure WCF issue with it.
This is not a complete answer but if you are using the client + server on the same machine you can use a named-pipe binding instead of netTcp
The binding section the configurations might look like this.
<netNamedPipeBinding>
<binding name="infiniteOpenBindingConfig" receiveTimeout="infinite" closeTimeout="infinite">
</binding>
</netNamedPipeBinding>
To keep the binding alive indefinitely the configuration above must be set both on server and client.
Try adding this to your netTcpBinding:
<reliableSession inactivityTimeout="infinite" enabled="true" />
And if that doesn't work, enable WCF tracing to find out what's killing it.

How to resolve WCF CommunicationException was unhandled

I have some problems.
the issue is CommunicationException error.
error message is
An error occurred while receiving the
HTTP response to
http://localhost:18080/WCFServices/TestService.
This could be due to the service
endpoint binding not using the HTTP
protocol. This could also be due to an
HTTP request context being aborted by
the server (possibly due to the
service shutting down). See server
logs for more details.
I wrote below source code.
TestServiceClient client = new TestServiceClient();
TestSettings[] voltages = client.GetTestSettings();
Error message appears above tilt word.
I want to synchronize Main Application and Client Application.
Above error is Client Application.
My app.config file is
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ITestService" 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="209715200"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:18080/WCFServices/TestService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITestService"
contract="TestServiceReference.ITestService"
name="WSHttpBinding_ITestService" />
</client>
</system.serviceModel>
</configuration>
ps. TestService is modified that is temporarily
please anyone.
thanks.
oh sorry, error occurred on "voltage"
I tried to increase maxsize and length.
but, it didn`t resolve this issue.
somebody help me.
Without seeing your server side config it's going to be hard to help you troubleshoot.
Having said that, one of the things you can do to get the real underlying exception (you're not seeing what's really going on) is to configure WCF Tracing. Just drop that config snippet in the config file on your server side, and look through the logs generated. That should point you to the real problem. Make sure to take it back out when you're finished.