I am trying to implement attachment functionality in one of my web application. It has three layer. Presentation, Business and Service Layer and i have blob datatype in database of attachment field....i am getting below Error while transferring data from business layer to service layer.
The remote server returned an unexpected response: (400) Bad Request
I cant find any solution even i tried with increase arraylength, buffersize etc...But still getting error...So if anyone have any idea than please help me....I am facing this issue since 5 days.....
Here is my web.config settings
<binding name="BasicHttpBinding_ITestService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="83886080" maxBufferPoolSize="83886080" maxReceivedMessageSize="83886080"
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>
turn on WCF tracing on server side by adding following section to WCF host's configuration file. you will be able to get more specific reason for your failure from the trace file.
<system.diagnostics>
<trace autoflush="false"/>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\temp\ServiceTrace.svclog"/>
</listeners>
</source>
</sources>
</system.diagnostics>
You need to use WCF streaming for the purpose of uploading large files. But still there are some limits for the approach being used. So transferring large files over HTTP needs a lot of considerations.
Detailed examples and consideration has been posted already at following links.
http://garfoot.com/blog/2008/06/transferring-large-files-using-wcf/
http://kjellsj.blogspot.com/2007/02/wcf-streaming-upload-files-over-http.html
need to use WCF streaming for the purpose of uploading large files. But still there are some limits for the approach being used. So transferring large files over HTTP needs a lot of considerations. Detailed examples and consideration has been posted already at following links. http://garfoot.com/blog/2008/06/transferring-large-files-using-wcf/
http://kjellsj.blogspot.com/2007/02/wcf-streaming-upload-files-over-http.html
Related
I'm trying to upload files via MVC and WCF.
My web.config on MVC project is configured to recive large files.
<binding name="BasicHttpBinding_IFile" closeTimeout="00:30:00"
openTimeout="00:30:00" sendTimeout="00:30:00" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Mtom" />
The problem occurs when I call my WCF. The endpoint is right on MVC project and the web.config on WCF has this binding:
<basicHttpBinding>
<binding name="FileUploadServiceBinding"
transferMode="Streamed"
messageEncoding="Mtom"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
receiveTimeout="00:30:00"
openTimeout="00:30:00"
closeTimeout="00:30:00"
sendTimeout="00:30:00">
<security mode="None">
<transport clientCredentialType="None" />
</security>
<readerQuotas maxDepth="100"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
I'm sending files of 25Mb and it's working, but when I try to upload files of 30Mb or more, my project can't reach the service, throwing this error message:
"There was no listening endpoint at http://localhost:55010/FileService.svc able to accept the message." This is usually caused by an incorrect SOAP address or action. Get more details. "
Thank you!
If you're hosting your service in IIS Express, or IIS, chances are the default value for the maxAllowedContentLength of the Request Filtering module is getting in the way (it's 30000000 by default).
Try increasing it by adding something like the following in your web.config file:
<system.webServer>
<security>
<requestFiltering >
<requestLimits maxAllowedContentLength="52428800" />
<requestFiltering>
</security>
</system.webServer>
I fixed the problem on server's web.config with the following line:
<httpRuntime targetFramework="4.5" enableVersionHeader="false" maxRequestLength="2147483647" executionTimeout="1600" requestLengthDiskThreshold="2147483647" />
Now my problem is the System.OutOfMemoryException when i'm trying to copy my stream to a memorystream, but it's out of this post escope.
Thank you guys!
I have a WCF web service which is hosted at a .svc file by ASP.NET. .svc file contains following configuration:
<%# ServiceHost Language="C#" Debug="true" Service="assembly.IPriceListProvider, assembly" Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf" %>
web.config contains configuration of the WCF. Here goes the binding configuration:
<binding name="basicHttpBinding_PriceListProvider" maxBufferSize="10485760"
maxReceivedMessageSize="10485760">
<readerQuotas maxArrayLength="16384000" />
</binding>
To test the service, I click on .svc file and click F5. WCF Test Client is opened. But the configuration has changed. The values which I've explicitly defined have now default values:
<binding name="basicHttpBindingEndPoint_PriceListProvider" 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>
Why does the configuration change? How do I persist original values?
I've heard something about simplified .svc configuration: a default binding for .svc is configured even if you don't specify it explicitly in web.config. Can it be the case?
The values for maxBufferSize and maxReceivedMessageSize are not propagated to the WSDL file that is published by your service. That´s why the wcf test client is unable to retrieve them and takes default values.
You can still change the values with the SvcConfigEditor every time you start the wcf test client. Therefor perform a right click on the config file in the wcf test client and look for bindings. But the changes will be lost, the next time you start the client.
You can also test your service with a self written client and set the values there like shown in the following example.
BasicHttpBinding binding= new BasicHttpBinding();
binding.MaxRecievedMessageSize = yourValue;
EndpointAddress endpointAddress = new EndpointAddress("the address");
ClientForContract client= new ClientForContract (binding,endpointAddress);
client.TheMethod();
client.Close();
Hope this helps!
I have a web application which enables users to upload files. The files are then saved using a WCF service on another service. This uploading works fine until I upload a file around 4.5 MB. When I upload a file above a certain size, I get the error:
Soap Error: 413 The server is refusing to process a request because the request entity is larger than the server is willing or able to process...
This error appears in the system event log of the server on which the WCF service is running.
The solutions that I've found have told me to change the maxAllowedContentLength and uploadReadAheadSize settings in the applicationHost config file. However changing the maxAllowedContentLength to only created a different error if I set it to something really small and changing the uploadReadAheadSize value didn't have any effect on the problem. Does anyone know what I have to change and where I have to change it? I've been looking for hours and I'm starting to get impatient :(. Thanks for the help!
EDIT:
Ok the web.config of the WCF Service located in the on the production system is as follows. This is the web.config located in the folder that the IIS Site of the WCF Web Services points to:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="SOAP" path="*.wsdl" verb="*" modules="IsapiModule" scriptProcessor="C:\Program Files (x86)\Common Files\MSSoap\Binaries\SOAPIS30.dll" resourceType="Unspecified" preCondition="bitness32" />
<add name="WSDL Mapping" path="*.wsdl" verb="*" modules="IsapiModule" scriptProcessor="C:\Program Files\Common Files\MSSoap\Binaries\SOAPIS30.dll" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
The configuration on the test system is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="WSDL Mapping" path="*.wsdl" verb="*" modules="IsapiModule" scriptProcessor="C:\Program Files\Common Files\MSSoap\Binaries\SOAPIS30.dll" resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
As you can see, there is no mention of any content length or anything in either one of the files. I have to admit, I'm pretty stumped at this point. But like I said, I'm no expert in things IIS.
EDIT 2:
Here is the serviceModel node of my web application's web.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WsJobsSoapBinding" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" 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://srvts01test:90/WsJobs.WSDL" binding="basicHttpBinding" bindingConfiguration="WsJobsSoapBinding" contract="JobsWs.WsJobsSoapPort" name="WsJobsSoapPort"/>
</client>
</system.serviceModel>
This is the web.config of my web application that calls the WCF service and not the web.config of the WCF service itself. Thanks again for any help :)
I found an article that talks about the 45KB size limit you mentioned in the chat. It includes the configuration changes that were made.
http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP
It's possible that your test environment has these changes made so that's one thing to look for/consider. People sometimes don't overwrite configuration files during deployment so you may have an old file there that just works.
You want to change the MaxReceivedMessageSize.
I think when I did this I also had to change the MaxBufferPoolSize to the same value.
You can do it via the config or via code like this.
binding.MaxBufferPoolSize = 67108864;
binding.MaxReceivedMessageSize = 67108864;
I was also having these 413 errors in my WCF Service, which was running under .Net 4.5.
The solution was simple.
Previously, my web.config contained this:
<services>
<service name="PocketCRMServices.Service1">
<endpoint address="../Service1.svc"
binding="webHttpBinding"
contract="PocketCRMServices.IService1"
behaviorConfiguration="webBehaviour" />
</service>
</services>
So, by default, it was already using the webHttpBinding binding.
To get rid of the 413 errors, I just needed to add this straight after this section:
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647777" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
And that's it.
I have an ASP.NET web application where i am using WCF 4 REST services to insert and get data from the database. But when trying to insert large amount of data like data for 1000 employees i am getting the error 'Unexpected End of File'.
Can anyone suggest a solution. Thanks in advance.
Have you tried setting the Max sizes in the web.config on the WCF services and possibly in the App/Web config file on the client side. It needs to look something like this:
<binding name="NewBinding0" sendTimeout="00:10:00" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
This should work for REST service.
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint helpEnabled="true" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647" automaticFormatSelectionEnabled="true">
<security mode="None"/>
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
I am deploying a web application to a remote server. I set up IIS 7 and the site comes up.
As part of the web application there is a service reference to a wcf service.
All of this works fine on my localhost everything runs.
I never did anything with the service itself on the deployment server. I just set up the web application in IIS. Now I am getting an socket exception error that could be from a few thing, I just want to eliminate my options......
My question is do I have to publish the service as part of my deployment process or since I published the web application with a service reference attached to it I should be ok?
Here is my web config portion of the service as you can see there is a reference to localhost (this cant be good) how is this resolved?
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IHSSWcfServices" 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://localhost:49506/IHSSWcfServices.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IHSSWcfServices"
contract="ServiceReference1.IHSSWcfServices" name="BasicHttpBinding_IHSSWcfServices" />
</client>
</system.serviceModel>
You do not have to publish the service as part of the deployment process for the application(otherwise, an ASP.NET application could never talk to an externally published service).
Just make sure that the service address you are trying to communicate with is the actual address of the hosted service (and not localhost, for instance, which would work on your machine, but not once it is deployed).
If you are writing the service and the client, the service does have to be deployed somewhere, and that somewhere must be accessible to the deployed location of the client. The deployment of the service is, however, independent of the deployment of the client.
Your system.ServiceModel section in config is clearly referencing the localhost. Try to change it to point to the actual IIS URL