I am using Message security and windows credential type. I am not using streaming and Mtom for some reason right now but might consider in the future. So far WCF service documentation specifies that you can transfer max up to 2GB of data. I am thinking if I can transfer 20-40 MB of data according to WCF specification, that will work for me now even though this is bad for now.
I can transfer data up to 10MB from WCF Service to Client but when I try to increase more than 10MB something is stopping it from transferring data from server to client and I don't know what.
I am transferring collection of objects from Web Service to Client.
When data doesn't transfer from Server to Client, I don't get any error message, this is very weird. When I set below transfer sizes to 10MB in client and server binding properties, I can transfer around collection of 1650 objects but when its around 1900, I don't get anything on client ???? WHY ????
Just to make it work I set all require property to max and its still not working.
Below is what I have in Client:
<ws2007HttpBinding>
<binding name="CustomizeWs2007HttpBinding" sendTimeout="00:10:00" closeTimeout="00:10:00"
openTimeout="00:10:00" messageEncoding="Text" receiveTimeout="00:10:00"
maxBufferPoolSize="0"
maxReceivedMessageSize="2147483647"
>
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true"/>
</security>
</binding></ws2007HttpBinding>
Below is what I have in WCF Service(Server):
<ws2007HttpBinding>
<binding name="KerberosBinding" maxBufferPoolSize="0" maxReceivedMessageSize="2147483647"
messageEncoding="Text" sendTimeout="00:10:00" closeTimeout="00:10:00"
openTimeout="00:10:00">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" />
<security>
<message negotiateServiceCredential="true" establishSecurityContext="true"/>
</security>
</binding></ws2007HttpBinding>
I hope somebody has an answer.
Thank you so much in advance.
Thank you Chris, its working now and Thank you for all others for your response.
I am a new member to this site so don't know where to put my final solution, anyway its pasted below:.
15728640 = 15MB
10485760 = 10MB though its too big
Client Config:
<behaviors>
<endpointBehaviors>
<behavior name="PServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="10485760"/>
</behavior>
</endpointBehaviors>
</behaviors>
and reference it from endpoint:
<endpoint address="http://localhost:53054/pservicehost/pservice.svc"
binding="ws2007HttpBinding" bindingConfiguration="PServiceWs2007HttpBinding" behaviorConfiguration="PServiceBehavior"
contract="PWebServiceContract.IPService" name="PServiceWs2007HttpBindingEndPoint">
Service Config:
<behaviors>
<serviceBehaviors>
<behavior name="PServiceHost.PServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="10485760"/>
</behavior>
</serviceBehaviors>
</behaviors>
and reference it from service:
<services>
<service behaviorConfiguration="PServiceHost.PServiceBehavior" name="PWebService.PService">
<endpoint address="" binding="ws2007HttpBinding" bindingConfiguration="KerberosBinding" contract="PWebServiceContract.IPService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
Maybe it has something to do with this throttle setting:
<dataContractSerializer maxItemsInObjectGraph="..."/>
I suggest you turn on WCF tracing on the server. It is a very useful tool. It helped me a lot in the past, especially if there are burried exceptions on the server side that you can't easily detect anywhere else.
Here is the link that explains how to turn it on: Service Trace Viewer Tool (SvcTraceViewer.exe)
Related
We have a WCF service with 4 service method & running well for last 4 years. Now client has requirement for a new service method which may return 10K to 1 million record. We have tested it with separate service and found that size of response xml is about 36MB to 200 MB and processing time it takes about 4 sec to 7-8 sec. We have made following changed in client webconfig file-
<bindings>
<basicHttpBinding>
<binding name="wsHttpBinding"
maxReceivedMessageSize="2147483647"
</binding>
</basicHttpBinding>
</bindings>
We have a fear that if we add this service method in existing service and changed maxReceivedMessageSize to max it may impact the memory consumption for whole service. And in case of simultaneous method call it may result out of memory kind of exception.
But client want to have this new service method in existing service. Please suggest what possible solution we can have. Client dont want to steam the information and sending as a zip file as for that they have to set up separate FTP location.
Thank,
#Niru
<system.serviceModel>
<bindings>
<basicHttpBinding>
<!-- Create a custom binding for our service to enable sending large amount of data -->
<binding name="MyBasicHttpBinding"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<readerQuotas
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<!-- Enable the serializer to serialize greater number of records -->
<behavior name="SilverlightWCFLargeDataApplication.Web.SilverlightWCFServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"/>
<services>
<!-- Bind the WCF service to our custom binding -->
<service behaviorConfiguration="SilverlightWCFLargeDataApplication.Web.SilverlightWCFServiceBehavior"
name="SilverlightWCFLargeDataApplication.Web.SilverlightWCFService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="MyBasicHttpBinding"
contract="SilverlightWCFLargeDataApplication.Web.SilverlightWCFService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
Read this article, maybe your answer.
https://smehrozalam.wordpress.com/2009/01/29/retrieving-huge-amount-of-data-from-wcf-service-in-silverlight-application/
i use WCF with Code First (VS 2012, .NET 4.0, WCF 5). Everything works fine unless i want to transfer an large object. It contains a list of many other objects. Every object has only small content. If this list is longer than 127 objects, i get an exception:
The server did not provide a meaningful reply; this might be caused by
a contract mismatch, a premature session shutdown or an internal
server error.
I found that out by reducing column count in database (try and error).
I use the following configuration on the client:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_****_Service" closeTimeout="00:00:10"
openTimeout="00:00:10" receiveTimeout="00:05:00" sendTimeout="00:05:00"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8000/****" binding="netTcpBinding"
bindingConfiguration="****" contract="****"
name="NetTcpBinding_****Service">
<identity>
<userPrincipalName value="****" />
</identity>
</endpoint>
</client>
</system.serviceModel>
The server configuration looks as follows:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_****_Service" closeTimeout="00:00:10"
openTimeout="00:00:10" receiveTimeout="00:05:00" sendTimeout="00:05:00"
transferMode="Buffered" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxConnections="0" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="100000" maxStringContentLength="100000"
maxArrayLength="100000" maxBytesPerRead="100000" maxNameTableCharCount="100000" />
<reliableSession enabled="false" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="****">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_****_Service"
contract="****" />
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8000/****" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Please excuse the masking of some names. I need to avoid that one can draw inferences from these names about the project. :D
At first, set this property on server side (just for dev)
<serviceDebug includeExceptionDetailInFaults="true" />
that specifies whether to include managed exception information in the detail of SOAP faults returned to the client for debugging purposes.
It's sure there is something wrong when processing your request but you don't have any debug information. That's why you have to set this property. You can also turn on WCF Tracing but it's a bit more difficult.
WCF have many quotas : A quota is a hard limit that prevents the use of additional resources once the quota value is exceeded.
There are especially two quotas you need to be aware when sending large data : maxReceivedMessageSize and MaxItemsInObjectGraph.
I have a WCF webservice with 1 functioning web method that takes a single string parameter.
I have a WinForms app that references the WCF webservice and it is all running on .NET 4.0.
Problem is that when I call the web method with too much data for the string data (around 4MB) this debugging both client and server on my local machine (Win 7 Pro 64bit, IIS 7) I get the following error (inner exception, exception):
The request was aborted: The request
was canceled.
An error (The request was aborted: The
request was canceled.) occurred while
transmitting data over the HTTP
channel.
When running on the production server I get a different message (stupid I'd didn't copy it) saying something along the lines of the server may have aborted the connection or similar.
If I reduce the data to around half (2MB) it works fine. The frustrating thing is I've maxed all the config settings, reset IIS, rebooted my machine but still it remains.
The web service validation code gets hit, validates user as okay and then as soon as it exits the validation dumps the message above back to the client. The stack trace when in the validation method (my code) shows only .NET stuff so there is no more of my code to debug, 8(.
On the server side I have this in the web.config:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service name="MyNS.MyService" behaviorConfiguration="MyNS.MyServiceBehavior">
<endpoint binding="wsHttpBinding" bindingConfiguration="httpWithMessageSecurity" contract="MyNS..MyService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyNS.MyServiceBehavior">
<serviceCredentials>
<serviceCertificate findValue="Server" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyNS.Validators.MyServiceUserValidator, MyNS./>
</serviceCredentials>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="httpWithMessageSecurity"
maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"/>
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
On the client side I have this in the app.config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="serviceHttpBinding"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8"
sendTimeout="01:00:00"
closeTimeout="00:00:20"
openTimeout="00:00:20"
receiveTimeout="00:20:00">
<readerQuotas
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"/>
<security mode="Message">
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="clientServerBehaviour">
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="PeerOrChainTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="http://mymachine/TheServices/Services/MyService.svc"
binding="wsHttpBinding" bindingConfiguration="serviceHttpBinding"
contract="DirectorySubmitService.IDirectorySubmitService" name="WSHttpBinding_IDirectorySubmitService">
<identity>
<dns value="Server" />
</identity>
</endpoint>
</client>
EDIT 1:
After enabled debug symbols in VS, after my validation code in the WCF service completes I get the following exceptions:
System.Web.HttpException: Maximum Length Exceeded
Stack: System.Web.HttpRequest.GetEntireRawContent()
Then:
System.ServiceModel.CommunicationException: Maximum Length Exceeded
Stack: System.ServiceModel.Activation.HostedHttpRequestAsyncResult.GetInputStream()
Subsequent CommunicationExceptions are related to Channels etc.. but all are the same error message.
I all so checked the app pool in IIS that was set to 30 MB as a request limit so I have run out maximum limits I can increase so this message is a real slap in the face.
Any help would be much apprecianted.
It turns out that the httpRuntime web.config element that I'd put to set the request limit to 50MB was being ignored because the location path I'd specified was missing a folder level, i.e. location path="MyService.svc" instead of location path="Services/MyService.svc".
The net result being it was using the default 4MB limit which of cause gave the max length exceeded message because that was exactly the case.
Doh!
I've got a WCF Web MEthod that takes in an XElement object as a parameter. For one of my XML files (sized at 600KB or so) this works just fine, however, for this bigger XML file (about 5MB) I get a CommunicationException right away.
I've already increased the message sizes for my binding. Below is the ServiceModel section of my web.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="BIMIntegrationWS.metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="BIMIntegrationWS.IntegrationService.customBinding0"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00">
<binaryMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binaryMessageEncoding>
<httpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="BIMIntegrationWS.BIMIntegrationWS" behaviorConfiguration="BIMIntegrationWS.metadataBehavior">
<endpoint address="" binding="customBinding" bindingConfiguration="BIMIntegrationWS.IntegrationService.customBinding0"
contract="BIMIntegrationWS.IBIMIntegrationService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
On the client, my ClientConfig looks like this:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_IBIMIntegrationService">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:1895/IntegrationService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_IBIMIntegrationService"
contract="BIMIntegrationService.IBIMIntegrationService" name="customBindingEndpoint" />
</client>
</system.serviceModel>
Thanks in advance!
try to add following snippet into your web.config for the service application:
<system.web>
<httpRuntime maxRequestLength="16384" /> <!-- 16MB -->
</system.web>
When you host the service in web server you also have to tweak allowed request size for the web server.
Best regards,
Ladislav
Maybe your XElement has too many nodes/child elements, and you need to set the maxItemsInObjectGraph attribute under dataContractSerializer to something larger?
You probably need to change the values of the attributes of the <readerQuotas /> sub element of <binaryMessageEncoding />.
For more information, see:
http://msdn.microsoft.com/en-us/library/ms731325.aspx
http://forums.silverlight.net/forums/p/88704/205040.aspx
Update:
Can you try to increase the maxAllowedContentLength as described here:
http://social.msdn.microsoft.com/Forums/en/wcf/thread/e6e21132-ad3f-4135-8ab9-77923b099907
Do you know how to turn off VS host and to just deploy to IIS and give it a ping. Normal IIS 7 on your dev box will do just fine. You can still attach debugger etc, just won't have instantaneous F5 gratification but since your ocode is not dying on startup you don't need to see if from the fist line anyway :-)
If you would need to attach very early you could could make a mimimal method that doesn't tounch anything at all and just returns int constnat - just to bring up app pool so you can attach.
I have a WCF service hosted in IIS7 (the service and client configuration is at the end of this post). I have run across an odd scenario that I was hoping someone might have some ideas about how to attack it and find a solution.
The service only exposes one contract, 'ProcessMessage'. I can send/receive synchronous messages from the service using that contract just fine with expected performance, but one particular call to that contract returns more than 65KB of data; about 1 MB. Upon originally calling it, I received the expected max receive size exceeded error. So I increased the maxReceivedMessageSize, and now this particular call takes 40 minutes to return to the client. This is well beyond any of the timeout settings, and well beyond what I would expect it to take. The server side processing time is only 2 seconds. It appears to be held up on the client side.
I've also tried bumping up several of the other quotas in the file to no avail.
Any thoughts would be greatly appreciated. Thanks.
Service Config:
<system.serviceModel>
<services>
<service behaviorConfiguration="Lrs.Esf.Facade.Startup.FacadeBehavior"
name="Lrs.Esf.Facade.Startup.FacadeService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="default" contract="Lrs.Esf.Facade.Startup.IFacadeService">
<identity>
<servicePrincipalName value="lrsdomain/PensionDev" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="default">
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Lrs.Esf.Facade.Startup.FacadeBehavior">
<!-- 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="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Client Config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IFacadeService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:1:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="52428800" maxReceivedMessageSize="6553600"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://esf2.facade.testpe.pg.local/FacadeWcf/FacadeService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IFacadeService"
contract="FacadeServiceReference.IFacadeService" name="WSHttpBinding_IFacadeService">
<identity>
<servicePrincipalName value="lrsdomain/PensionDev" />
</identity>
</endpoint>
</client>
You didn't increase the size of the various parameters on the server side, it seems - you should definitely try that! Use the binding configuration from your client config file on the server side as well - the service might well be choking since it's still defaulting to 64K message size.
Also, the receiveTimeout in your client binding is a bit funny - it's missing a zero digit:
<binding name="WSHttpBinding_IFacadeService"
receiveTimeout="00:1:00"
You should use receiveTimeout="00:01:00"
Marc
I have figured out the basic cause of the issue and a work-around, however additional insight would be great.
The DataSet was getting serialized in XML format by WCF. I forced the DataSet to serialize as a byte[] and the time reduced to 4 seconds. One guess is that escaping all of the characters in 4MB of XML so that the HTTP communication was valid is what caused the problem.