I feel like this has probably been answered and maybe I am not searching with the right terms.
I have a WCF service that acting like a proxy. It is a middle man for two services that normally can talk to each other, but now go through this new service.
Old:
A -> B
New:
A -> MM -> B
I need to expose the same contract as a service endpoint (for "A" to talk to "MM") and as a client endpoint (for "MM" to talk to "B").
Can these two share a binding configuration and just give the endpoints different names? Or is there a better way to handle this scenario?
(inside of <system.serviceModel> tag)
<client>
<endpoint address="http://<remoteaddress>/" binding="basicHttpBinding"
bindingConfiguration="MyBinding" contract="IService" name="ToB" />
</client>
<services>
<service behaviorConfiguration="Behavior" name="Service">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="MyBinding" name="FromA" contract="IService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/MyService" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="MyBinding" closeTimeout="00:15:00" openTimeout="00:15:00"
receiveTimeout="00:15:00" sendTimeout="00:15:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2048000000" maxBufferPoolSize="2048000000"
maxReceivedMessageSize="2048000000" messageEncoding="Text"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="4065536" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
Edit:
The error message with this setup is:
com.vsp.cal.webservice.external.SystemFault
Stack:
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
A change in name is not enough to uniquely define an endpoint. Instead goes back to the old "ABC" - address, binding, contract. At least one of those must be different to uniquely define a new endpoint.
http://msdn.microsoft.com/en-us/library/ms733107(v=vs.100).aspx
Does this help?
Thank you to everyone who looked this over and tried to help!
In the end it was not the configuration, but a stupid coding error. The cryptic error message is the response from the other side (a Java web service). It wasn't happy because I was sending a null object due to a failed cast.
So the answer is that this configuration DOES WORK when you don't code like an idiot.
Related
I have a WCF web services which keep giving me a 413 response when I post a large JSON request to it, I have added the maximum limit into the web.config but it seems they are ignored, I would like to know is there anything wrong in my web.config?
Here is my web.config
<system.serviceModel>
<services>
<service name="myService">
<endpoint address="http://localhost/myService" binding="webHttpBinding"
bindingConfiguration="myBinding" name="myService"
contract="ImyService" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="myBinding" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
Thanks!
EDITED:
I have "solved" the problem, by adding a new binding with name = "", which overwrite the default binding setting, and everything goes fine.
Being said, myBinding is actually being ignored or not bound to my service endpoint...
Can anyone figuring out the reason behind??
This is my first WCF service project writing both client and server side. I'm from a Windows Forms background.
I think I've been having problems with packet/receive buffer size but I don't have a clue how to test whether my app.config is working correctly or what I've done wrong.
The client project's app.config is set as follows and it's testproj.exe.config reflects the contents correctly
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IPulseWebService"
closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true">
<readerQuotas
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="blah"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPulseWebService"
contract="ServiceReference1.IPulseWebService" name="WSHttpBinding_IPulseWebService">
<identity>
<dns value="localhst" />
</identity>
</endpoint>
</client>
</system.serviceModel>
My web service's webservice.dll.config contains the following service.serviceModel section
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IPulseWebService"
closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true">
<readerQuotas
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
</wsHttpBinding>
<basicHttpBinding>
<binding name="BasicHttpBinding_IPulseWebService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
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>
<services>
<service name="SmartcentreWcfLib.PulseWebService">
<host>
<baseAddresses>
<add baseAddress="http://l0calhost:8732/Design_Time_Addresses/SmartcentreWcfLib/PulseWebService/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IPulseWebService"
contract="SmartcentreWcfLib.IPulseWebService">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="l0calhost" />
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
In my server side wcf dll, I have the following function just as a test to return some rows of data. Each row is a set of key/value pairs stored in an Dictionary. Each object should be a simple byte[] or variable type.
List<IDictionary<string, object>> IAuditV1.ReadAuditForStaffMember(long staffId, DateTime startDate,
DateTime endDate, Int32 recordCount)
{
List<TableAdminAudit> tempResult = DatabaseInterface.Instance.AuditQueries.ReadAdminAudit(staffId, startDate,
endDate, recordCount);
return tempResult.Select(record => record.PrepareForWebInterface()).Cast<IDictionary<string, object>>().ToList();
}// function
In my client application I am running the following loop, which simply increments the number of received records.
Int32 totalRecords = 0;
while (true)
{
results = client.ReadAuditForStaffMember(1, DateTime.MinValue, DateTime.Now, totalRecords);
totalRecords += 10; //results.Length;
if (totalRecords == 0) break;
}
On the 3rd loop when the returned buffer reaches 30 records in size I receive the following error message.
I looked up the error and forums suggested it relates to the connection closing before the whole data had been received so change the various buffer sizes etc. As you can see from my config files, I've upped all the values I'm aware of to 2147483647 but it's not worked.
So I don't know where to go from here. Can anybody help please?
System.ServiceModel.CommunicationException occurred
HResult=-2146233087
Message=An error occurred while receiving the HTTP response to blah2/Design_Time_Addresses/SmartcentreWcfLib/PulseWebService/. 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.
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at WcfTester.ServiceReference1.IPulseWebService.ReadAuditForStaffMember(Int64 staffId, DateTime startDate, DateTime endDate, Int32 startIndex)
at WcfTester.ServiceReference1.PulseWebServiceClient.ReadAuditForStaffMember(Int64 staffId, DateTime startDate, DateTime endDate, Int32 startIndex) in W:\Projects\pulse.smartcentre.root\pulse.smartcentre\WcfTester\Service References\ServiceReference1\Reference.cs:line 481
at WcfTester.Program.Main(String[] args) in W:\Projects\pulse.smartcentre.root\pulse.smartcentre\WcfTester\Program.cs:line 40
InnerException: System.Net.WebException
HResult=-2146233079
Message=The underlying connection was closed: An unexpected error occurred on a receive.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
InnerException: System.IO.IOException
HResult=-2146232800
Message=Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Source=System
StackTrace:
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
InnerException: System.Net.Sockets.SocketException
HResult=-2147467259
Message=An existing connection was forcibly closed by the remote host
Source=System
ErrorCode=10054
NativeErrorCode=10054
StackTrace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
InnerException:**
The file something.dll.config is never used. You need to copy those settings into the web.config or servicehost.exe.config file.
This is how .NET has worked since Day 1, and is not specific to WCF. Consider that a given DLL can be used by multiple "executables", and each of these may have different settings for the DLL.
I'm trying to build a WCF Application service, using FW4.0.
My service work correctly when transferring EntiryFramework object between Server and client. But I'm having problem passing EF object from Client to Server.
Here some more detail about my environment:
- The service is running in debug mode locally on IIS
- I'm running all this on my Windows 7
- I'm using Visual Studio 2010 on FW4.0
I'm trying to send a object (tblClient) to server to save the record, but a keep having the error (413) Request Entity Too Large.
Here the full stack:
System.ServiceModel.ProtocolException occurred
HResult=-2146233087
Message=The remote server returned an unexpected response: (413) Request Entity Too Large.
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at ClientApp.ServiceReference1.IService.SaveClient(tblClient client)
at ClientApp.ServiceReference1.ServiceClient.SaveClient(tblClient client) in C:\dufh\WPF Project\ClientApp\Service References\ServiceReference1\Reference.vb:line 2383
at ClientApp.ViewModel.ClientViewModel.SaveClient() in C:\dufh\WPF Project\ClientApp\ViewModel\ClientViewModel.vb:line 48
InnerException: System.Net.WebException
HResult=-2146233079
Message=The remote server returned an error: (413) Request Entity Too Large.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
InnerException:
I've do some research and all point to the maxBufferSize and/or maxBufferPoolSize and/or maxReceivedMessageSize witch is not large enough in the Client config App.Config. So I inscresed them to maximum value :
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
But still the error remain.
Here my full Client App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="MVVM Sampling"/>
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:7803/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService" contract="ServiceReference1.IService"
name="BasicHttpBinding_IService" />
</client>
</system.serviceModel>
</configuration>
and the full Web.Config WCF service Web.Config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxDepth="200" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<connectionStrings>
<add name="MaitreEntities" connectionString="metadata=res://*/Schemat.csdl|res://*/Schemat.ssdl|res://*/Schemat.msl;provider=System.Data.SqlClient;provider connection string="data source=INFOFILE2\SQL2008R2;initial catalog=0001ConneryFerland;user id=sa;password=kermit80;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
Any help would be very welcome :-)
For the record
I think I got it.
The Web.Config from the service does not have the binding information.
I placed this info in it, and voila!
<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
Note here that the binding did not have a name specified.
You don't have an explicit endpoint (meaning one defined in your config file) for your service, so the binding configuration you declared ("BasicHttpBinding_IService") isn't being used. WCF is providing a default endpoint along with a default binding (basicHttpBinding unless you overrode it in the protocolMapping section of the config file).
You have two ways to resolve this in your service's config file:
You can make the "BasicHttpBinding_IService" configuration the default by removing the name attribute:
<binding maxBufferPoolSize="2147483647".....
Or you define an endpoint explicitly in the config and assign your binding configuration to the bindingConfiguration attribute of the endpoint.
<services>
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService"
contract="ServiceReference1.IService" />
</services>
If you create custom binding e.g. MybasicBinding,
<basicHttpBinding>
<binding name="MybasicBinding" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="32" maxBytesPerRead="200000000"
maxArrayLength="200000000" maxStringContentLength="200000000" />
</binding>
</basicHttpBinding>
To avoid the 413 error, Do not foreget to Specify the bindingConfiguration="MybasicBinding" for service endpointas,
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="MybasicBinding" contract="WCFService.IService" />
Another way to fix this and have a better look at web.config file, is to edit the web.config file with the "Microsoft Service Configuration Editor" (C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\SvcConfigEditor.exe)
if no binding is specified and httpsgetenabled is true then you may need to set basichttpsbinding in your service application's web.config
<bindings>
<basicHttpsBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpsBinding>
I was getting this error. I discovered that I had created the binding configuration, but failed to set the endpoint to that configuration. Therefore, the endpoint was using an unnamed binding configuration with the default settings. So, maxReceivedMessageSize was 65k.
This can also be due to IIS restriction.
IIS Manager-> Select your application-> Features Veiw->Request Filtering->Edit Feature Settings->Maximum Allowed Content Length 30000000(28.6M)-> Increase the value
I have a windows service and a winform application that communicate between each other using WCF through TCP.
I sometimes have to exchange huge data and I encountered a CommunicationException on the client. Now I have trouble finding which property to change and where (on the server side or the client side?).
The problem occurs when the server is returning a value to the client that is a 2-uple (my own implementation) of two arrays of doubles: Tuple<Double[], Double[]> (both arrays have always the same length).
I have noticed that there is no error when the arrays have a length of 22 000, but the CommunicationException is thrown when arrays have a length of 44 000.
Here's my App.config file regarding the netTcpBinding part:
On the server:
<netTcpBinding>
<binding name="MyBindingConf"
maxReceivedMessageSize="5000000"
sendTimeout="00:05:00">
<readerQuotas maxArrayLength="67108864"
maxStringContentLength="67108864"/>
<security mode="None" />
</binding>
</netTcpBinding>
On the client:
<netTcpBinding>
<binding name="MyBindingConf"
maxReceivedMessageSize="5000000"
sendTimeout="00:59:00">
<readerQuotas maxArrayLength="67108864"
maxStringContentLength="67108864"/>
<security mode="None" />
</binding>
</netTcpBinding>
Could you point on which property to change and on which side?
P.S: It's not a timeout problem.
EDIT
I have now the same nettcpbindingconfiguration on both server and client:
<bindings>
<netTcpBinding>
<binding name="MyBindingConf"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
sendTimeout="00:30:00">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
And the same serviceBehavior:
<behaviors>
<serviceBehaviors>
<behavior name="Debug">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
I then get a NetDispatcherFaultException on the client, advising me to increase maxArrayLength or maxItemsInObjectGraph. But for me, these values are already largely set for what I need to transfer and also set to the max values!
Here's the InnerException message:
The maximum array length quota (19502) or the maximum items in object graph quota has been exceeded while reading XML data. These quotas may be increased by changing the MaxArrayLength property on XmlDictionaryReaderQuotas or the MaxItemsInObjectGraph setting.
Any clue? Where does this 19 502 figure comes from?
On both, the server and client you have to configure the attribute of your binding, if you are exchanging large amounts of data between them. For example:
<binding name="LargeSettings" maxBufferSize="20000000" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00">
<readerQuotas maxDepth="32" maxStringContentLength="200000000" maxArrayLength="200000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None" />
</binding>
Work your way from the large values to find the one that suits you.
EDIT:
In Client side, you need to configure a behavior, and set that behavior in the client endpoint. Something like this:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="debug"> <dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
And you set the behavior in the client endpoint:
<endpoint name="myEndpoint" behaviorConfiguration="debug">
Your other settings...
</endpoint>
Hope this helps.
Personally I would increase the MaxReceivedMessageSize, ensuring that maxBufferSize is also adjusted. These are the common areas that we have needed to adjust.
Here's a copy of a wsHttpBinding that I haved used in tests to successfully transfer huge chunks of data. I'm not saying these values are best practices, but they work to pass big chunks of data.
<binding name="WSHttpBinding_LargeData"
maxBufferPoolSize="524288"
maxReceivedMessageSize="99999999">
<readerQuotas
maxDepth="128"
maxStringContentLength="8192"
maxArrayLength="163840000"
maxBytesPerRead="4096"
maxNameTableCharCount="16384"
/>
</binding>
Did you try maxItemsInObjectGraph in your service behavior
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
I'm having a WCF Service that uses wsHttpBinding. The server configuration is as follows :
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
At the client side I'm including the Service reference of the WCF-Service. It works great if I have limited functions say 90 Operation Contract in my IService but if add one more OperationContract than I'm unable to Update the Service reference nor i'm able to add that service reference. In this article it's mentioned that by changing those config files(i.e devenv.exe.config, WcfTestClient.exe.config and SvcUtil.exe.config) it will work but even including those bindings in those config files still that error pops up saying
There was an error downloading 'http://10.0.3.112/MyService/Service1.svc/mex'.
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved: 'http://10.0.3.112/MyService/Service1.svc/mex'.
There is an error in XML document (1, 89549).
The maximum nametable character count quota (16384) has been exceeded while reading XML data. The nametable is a data structure used to store strings encountered during XML processing - long XML documents with non-repeating element names, attribute names and attribute values may trigger this quota. This quota may be increased by changing the MaxNameTableCharCount property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 89549.
If the service is defined in the current solution, try building the solution and adding the service reference again.
Any idea how to solve this????
Try the following:
In the installation directory of your Visual Studio where devenv.exe is located (e.g. C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE) add this section to the devenv.exe.cofig
<system.serviceModel>
<client>
<endpoint binding="customBinding" bindingConfiguration="largeServiceBinding" contract="IMetadataExchange" name="http" />
</client>
<bindings>
<customBinding>
<!-- NOTE: The binding name must be the same as specified in the config file of the wcf service -->
<binding name="largeServiceBinding" >
<textMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport transferMode="Buffered" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</binding>
</customBinding>
</bindings>
</system.serviceModel>
in the app.config of your WCF-service add the same binding:
<bindings>
<customBinding >
<!-- NOTE: The binding name must be the same as specified in the devenv.exe.config file located ..\Common7\IDE folder of the VS installation directory -->
<binding name="largeServiceBinding" >
<textMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport transferMode="Buffered" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</binding>
</customBinding>
</bindings>
Note that the name attribute of the binding tags from the two files must match (e.g. largeServiceBinding)
Finally add the following mex endpoint into your service tag:
<endpoint address="mex" binding="customBinding" contract="IMetadataExchange" bindingName="testBinding" bindingConfiguration="largeServiceBinding" name="http"/>
this may look like this:
<services>
<service behaviorConfiguration="MyServiceBehavior"
name="MyService.MyService">
<endpoint address="" binding="wsHttpBinding" contract="MyService.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="customBinding" contract="IMetadataExchange" bindingName="testBinding" bindingConfiguration="largeServiceBinding" name="http"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/MyService/MyService/" />
</baseAddresses>
</host>
</service>
</services>
I know it has been a while, but I got the same problem and found other (simpler) solution in codeproject
In the solution given there the values are set in the code rather than the .config file.
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.MaxReceivedMessageSize = 50000000;
binding.ReaderQuotas.MaxArrayLength = 50000000;
binding.ReaderQuotas.MaxStringContentLength = 50000000;
binding.ReaderQuotas.MaxNameTableCharCount = 50000000;
EndpointAddress endpoint = new EndpointAddress(new Uri("https://server/EWS/Exchange.asmx"));
ExchangeServicePortTypeClient ews = new ExchangeServicePortTypeClient(binding, endpoint);
However, I changed the values in the relevant values in the .config file ( in both the <binding> and the <readerQuotas> sections) and solved the problem (rather than adding custom bindings):
<binding name="ITransactionProcessor" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="50000000" maxBufferPoolSize="524288" maxReceivedMessageSize="50000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="50000000" maxArrayLength="50000000"
maxBytesPerRead="4096" maxNameTableCharCount="50000000" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
I hope this will help somebody :)
One thing to recognize is that the message refers to the svcutil reader quotas not the service ones! Svcutil has a limit on how much metadata it can read. This limit can be changed with a config file. The solution is to create a config file for svcutil and place it in the same folder as the tool. Next time you run svcutil, the config file values will be taken into account.
http://geekswithblogs.net/claraoscura/archive/2007/08/20/114806.aspx
in your app.config or dll.config on the the client add:
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="myMex" maxReceivedMessageSize="1024000"> <!-- modify this to avoid stupid error -->
<readerQuotas maxNameTableCharCount="163840" /> <!-- DO NOT touch this one -->
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
...
<client>
<endpoint binding="netTcpBinding" bindingConfiguration="myMex"
contract="IMetadataExchange" name="net.tcp" />
...
</client>
</system.serviceModel>
</configuration>
And there you go!
This is one of the really annoying things with WCF and as often google just yields you alot of bs. Wasted tons of time with this.