I have a WCF SOAP service and I am trying to submit a file to the service that is too large (128KB). I have scoured the internet and found many suggestions about adding the maxReceivedMessageSize, maxBufferSize, and other such attributes, but to no avail. I have also added the maxRequestLength to the httpRuntime but that doesn't work either. Not matter what I do I keep getting
HTTP Error 413: Request Entity Too Large.
Error
HTTP Error 413: Request Entity Too Large.
Web Config
<httpRuntime targetFramework="4.5.1" maxRequestLength="1048576"/>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SomeBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" openTimeout="00:20:00"
receiveTimeout="00:20:00" closeTimeout="00:20:00" sendTimeout="00:20:00">
<readerQuotas maxDepth="200" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Even though you've set larger quotas in your binding, that binding is not being used by your service because it's never assigned to an endpoint or set as the default binding for basicHttpBinding.
Since you don't have an explicit endpoint defined in your config file, you can set your binding configuration as the default for basicHttpBinding by omitting the name attribute, like this:
<binding maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
openTimeout="00:20:00"
receiveTimeout="00:20:00"
closeTimeout="00:20:00"
sendTimeout="00:20:00">
<readerQuotas maxDepth="200"
maxStringContentLength="8388608"
maxArrayLength="16384"
maxBytesPerRead="2147483647"
maxNameTableCharCount="16384" />
</binding>
Without making it the default for all requests that use basicHttpBinding (or assigning it to an explicit endpoint), the service will create the binding with the default (and smaller) values.
For more information on default bindings (and endpoints and behaviors), see A Developer's Introduction to Windows Communication Foundation 4.
#Tim I have seen this in several spots online and it is correct, except that you are missing something else. I was getting confused since I am new to WCF and my service wraps another service so that I can perform new logic without changing the existing system. Therefore any changes I was making were only getting applied to the client I am calling into. You need to add the below <services> to the <system.serviceModel> in order for those changes to be applied to the service.
<services>
<service name="ANX.DEX001.WebService.EtPrintService">
<endpoint name="basicHttpBinding"
address="/EtPrintService.svc"
binding="basicHttpBinding"
contract="ANX.DEX001.WebService.IEtPrintService"
bindingConfiguration="APIPortBinding"/>
</service>
</services>
Related
I have a WCF service that is working great in production except for one new instance of a client that is unable to communicate with the service.
The WCF service runs over https on .Net 4.0 on a Windows Server 2008 R2 system. All clients are .Net 4.0 or higher (these are not under my control/config).
Enabling WCF Tracing in the service when this one client fails to connect shows this error:
"Failed to lookup a channel to receive an incoming message. Either the endpoint or the SOAP action was not found."
I have verified the exact same URL and WSDL are used by working clients and the one nonworking client. I CAN view the service information site and WSDL over https using a web browser.
I am suspecting a possible SSL/TLS negotiation failure, but wanted to check to see if others are familiar with this particular type of situation.
Here is my service web config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_INamedService">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="NamedService.NamedServiceService">
<endpoint address="/NamedServiceService" binding="basicHttpBinding" bindingNamespace="https://my.domain.com/NamedServiceService" bindingConfiguration="BasicHttpBinding_INamedServiceService" contract="NamedServiceService.INamedServiceService" />
</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 httpsGetEnabled="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>
</configuration>
Possibly a typo in your endpoint bindingConfiguration:
bindingConfiguration="BasicHttpBinding_INamedServiceService"
Your binding is named: BasicHttpBinding_INamedService not BasicHttpBinding_INamedServiceService
<basicHttpBinding>
<binding name="BasicHttpBinding_INamedService">
<security mode="Transport" />
</binding>
</basicHttpBinding>
not sure what your contract name is but it does have ServiceService in it too, might want to double check that out.
If it is in the same project, why is your service implement and service interface namespace different? There may be some spelling mistakes in your configuration. I suggest you check it carefully.
name="NamedService.NamedServiceService"
contract="NamedServiceService.INamedServiceService"
Besides, try to use the following configuration to set up https protocol.
<bindings>
<webHttpBinding>
<binding name="myhttpsbinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
<binding name="myhttpbinding">
<security mode="None"></security>
</binding>
</webHttpBinding>
</bindings>
Feel free to let me know if there is anything I can help with.
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 am trying to pass large byte array to wcf service from windows phone application. I have tried all possible way's to pass large byte array but I couldn't pass it.
Here is my web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<!--<binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" receiveTimeout="00:10:00" closeTimeout="00:10:00">
<security mode="None" />
</binding>-->
<binding closeTimeout="01:30:00"
openTimeout="01:30:00" receiveTimeout="01:30:00" sendTimeout="01:30:00" transferMode="Streamed"
maxBufferSize="2147483646" maxBufferPoolSize="2147483646" maxReceivedMessageSize="4294967295">
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646"
maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
<security mode="None">
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
I have used the max received message size i.e. 2147483646. Now I will show my
ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://xxx.xx.x.xxx/WebService/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="MyService.IService1" name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
I am passing following parameter to my wcf service method
Service1.svc.cs
public string GetDataUsingDataContract(byte[] fileByte,string fileName,string folderName)
{
}
I have searched a lot and I found one similar example Maximum array length quota
But I heard that windows phone 8 doesn't support netTcpBinding. I have read that we can pass 2GB file to wcf service. How can I pass max byte array? I am stuck with this problem. Can someone please help me to solve this?
This is quite a common exception - have a look at the following posts on msdn social:
http://social.msdn.microsoft.com/Forums/wpapps/en-US/4fe7c526-510d-46ab-acac-9719e696f7db/an-exception-of-type-systemservicemodelcommunicationexception-occurred-in
http://social.msdn.microsoft.com/Forums/wpapps/en-US/61f1060f-846e-4e7d-b8ff-c2956e0a8677/visual-studio-2012-windows-phone-8-wcf-systemservicemodelcommunicationexception
Both seem to point to a problem with the windows 8 phone emulator. Instructions on how to work around this here:
http://countofmontecito.com/2012/11/13/wcf-and-windows-phone-8/
Full documentation here:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj684580(v=vs.105).aspx
I'm looking for a definitive answer as to whether what I'm trying to do is supported or not.
Basically, I'm using WCF to stream large MTOM attachments (200 Mb), this works perfectly fine. The security requirements for the service is to use HTTPS and certificate-based authentication. I can run the service over HTTPS without any problems, but once I set IIS to “Accept client certificates” or “Require client certificates” (no change in the code), the following error is thrown (but only once the attachments get over about 80 Mb or so):
The socket connection was aborted.
This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue.
Local socket timeout was '00:30:00'.
I found some resources, sorry can't find them now, that indicated that the failure is probably related to the fact that the incoming messages either cannot be digitally signed, or verified due to the streaming nature of the message contents. I believe the service would have to hash the whole message contents to verify the cert, but this can't be achieved because portions of the message are in transit while validation is trying to occur.
I've setup the message contract so that the body is a single Stream element, and the other elements are contained within the header:
<MessageContract()>
Public Class StreamAttachmentRequest
<MessageHeader(MustUnderstand:=True)>
Public Property AttachmentName As String
<MessageBodyMember(Order:=1)>
Public Property Attachment As Stream
End Class
The service configuration looks as follows:
<system.serviceModel>
<!-- BINDING -->
<bindings>
<basicHttpBinding>
<binding name="TestCaseBasicBinding"
messageEncoding="Mtom"
transferMode="StreamedRequest"
maxReceivedMessageSize="2147483647"
closeTimeout="00:30:00"
openTimeout="00:30:00"
receiveTimeout="00:30:00"
sendTimeout="00:30:00">
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
<readerQuotas maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<!-- BEHAVIORS -->
<behaviors>
<serviceBehaviors>
<!-- TEST CASE SECURE BEHAVIOR -->
<behavior name="TestCaseSecureBehavior">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<serviceCertificate
storeLocation="LocalMachine"
storeName="My"
findValue="DistinguishedNameOfCert"
x509FindType="FindBySubjectDistinguishedName" />
<clientCertificate>
<authentication certificateValidationMode="ChainTrust"/>
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<!-- SERVICES -->
<services>
<service name="StreamingMutualAuthTestCase.Web.Service.TestCaseServiceImplementation"
behaviorConfiguration="TestCaseSecureBehavior">
<!-- SERVICE -->
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="TestCaseBasicBinding"
contract="StreamingMutualAuthTestCase.Web.Service.ITestCaseService" />
<endpoint contract="IMetadataExchange" binding="mexHttpsBinding" address="mex" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
The client configuration looks like this:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITestCaseService" closeTimeout="00:30:00"
openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
maxReceivedMessageSize="2147483647" messageEncoding="Mtom"
transferMode="Streamed">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Certificate" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<!-- BEHAVIORS -->
<behaviors>
<endpointBehaviors>
<behavior name="SecureClientBehavior">
<clientCredentials>
<clientCertificate
storeLocation="LocalMachine"
storeName="My"
findValue="DistinguishedNameOfCert"
x509FindType="FindBySubjectDistinguishedName"/>
<serviceCertificate>
<authentication certificateValidationMode="ChainTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="https://test7/TestCaseService/TestCaseService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ITestCaseService"
contract="TestCaseService.ITestCaseService"
name="BasicHttpBinding_ITestCaseService"
behaviorConfiguration="SecureClientBehavior"/>
</client>
</system.serviceModel>
Once again, this will work just fine until I set IIS Client Certs to either Accept or Require.
Also, there is a 413 error in the IIS log...
2011-08-18 15:00:06 W3SVC1 10.39.8.111 POST /TestCaseService/TestCaseService.svc - 443 - 10.75.13.81 - - - test7 413 0 0
I've already designed an authentication service on top of my file upload service to work around the issues; but I'd really like to know if what I'm trying to do is 'do-able' or not.
Thanks a ton - Patrick
If you want to turn on client certificates in IIS you must do the same for your service (and client):
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
Your client must provide certificate to the proxy:
yourProxy.ClientCredentials.ClientCertificate.SetCertificate(...);
Also your server must trust these certificates so client certificates must be either issued by certification authority trusted by the server or they must be installed to LocalMachine\Trusted people store directly on the server.
WCF endpoints don't support "Accept client certificates" - you must either use client certificates or not.
Searched with no luck...
I keep getting
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
It makes sense, so I go into both Server and client config and make the change:
Client
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFileUpload"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed" messageEncoding="Text" maxBufferSize="65536" maxReceivedMessageSize="67108864">
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/services/FileUpload.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFileUpload"
contract="CFTW.FileUpload.IFileUpload" name="BasicHttpBinding_IFileUpload" />
</client>
</system.serviceModel>
Server
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IFileUpload"
transferMode="Streamed" messageEncoding="Text" maxBufferSize="67108864" maxBufferPoolSize="67108864" maxReceivedMessageSize="67108864">
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="BasicHttpBinding_IFileUpload">
<endpoint address="~/services/FileUpload.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IFileUpload"
contract="CFTW.FileUpload.IFileUpload"></endpoint>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
I'm not sure why it's not working (otherwise I'd fix it:)). It's running on .NET 4.0 RC.
I just ran into this issue. I found that my custom binding did not get applied at all. Then I used name = "" in binding tag. Then everything started working with the new settings. This is due to .NET 4.0 comes with default binding/endpoint/behavior configurations. These default settings have name = "". I just modified the default binding itself. The reason for my custom binding(named) did not get applied is due to the value for the name in <service> tag. It should follow <Namespace.ServiceClassName>.
You need to increase the attribute maxReceivedMessageSize in the client config for the binding. Also, be sure to set the same value for the maxBufferSize. For buffered connection these two values need to be same.
Had the same problem, luckily in a second project and could compare with the working project. The difference was that the working project had additional attributes set in the web.config for the service bindings...
Working sample:
httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
The second project only had:
httpsTransport
Also do a search in your project for 65536 as it is also defined in configuration.svcinfo and configuration91.svcinfo of the service reference.