I'm trying to upload photo(attachment stream) through window service , using REST configuration (webHttpBinding), but I get this exception
here is the binding configuration I used (I tried all of them and the error still as it )
<webHttpBinding>
<binding name="maxRequest" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode ="Transport"></security>
</binding>
<binding name="maxRequestBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode ="Transport">
</security>
</binding>
<binding name="BasicHttpBinding_IFileService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered" useDefaultWebProxy="true"
>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode ="Transport"></security>
</binding>
I had also tried the solution for IIS posted here
https://techcommunity.microsoft.com/t5/iis-support-blog/solution-for-request-entity-too-large-error/ba-p/501134
however, all of the above doesn't work.
here is my endpoint behavior
<endpointBehaviors>
<behavior name="rest">
<webHttp faultExceptionEnabled="true" helpEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="1365536" />
</behavior>
</endpointBehaviors>
here is the contract
and For more information the image size is just 100KB.
WCF default transmission message size is 64KB, you need to use MaxReceivedMessageSize to set the transmission message size.
<system.serviceModel>
<services>
<service name="ConsoleApp1.RawDataService" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8012/ServiceModelSamples/service"/>
</baseAddresses>
</host>
<endpoint address=""
binding="webHttpBinding"
contract="ConsoleApp1.IReceiveData"
behaviorConfiguration="ESEndPointBehavior" bindingConfiguration="RestfullwebHttpBinding"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="RestfullwebHttpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ESEndPointBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
You need to apply RestfullwebHttpBinding to the endpoint.
Feel free to let me know if the problem persists.
Related
I have a really annoying problem regarding with WCF Services. I have a wcf service which has basichttpbindng.
The service is published to Azure Web App and timeout is set to 20 minutes. After 180 seconds I get the following error:
The underlying connection was closed: The connection was closed
unexpectedly
I have a method like following:
public ProcessResult TestErrorMessage()
{
try
{
System.Threading.Thread.Sleep(320000);
return new ProcessResult()
{
};
}
catch (Exception ex)
{
throw ex;
}
}
[OperationContract]
ProcessResult TestErrorMessage();
You can find both Config below.
Server Config:
<bindings>
<basicHttpBinding>
<binding name="basicBindingConfiguration" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<!--<security mode="None">-->
<security mode="Transport">
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Tefal.WebService.Integration.DivaIntegration" behaviorConfiguration="customBehavior">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicBindingConfiguration" contract="Tefal.WebService.Integration.IDivaIntegration" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="customBehavior">
<!--<serviceMetadata httpsGetEnabled="false" />-->
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
Cleint config:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDivaIntegration" closeTimeout="00:20:00"
openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
useDefaultWebProxy="true">
<security mode="Transport" />
</binding>
<binding name="BasicHttpBinding_IDivaIntegration1" receiveTimeout="00:20:00"
sendTimeout="00:20:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ClientBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
I have a problem with the MaxReceivedMessageSize attribute, I have all the settings done, but I keep getting the message related to value exceeded (65536)
Can you help me identify the problem in the configuration?
Thank you
This is my web.config file
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Binding1" closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
messageEncoding="Text">
<security mode="None" />
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="saam.mdlw.srv.aep.SerBehavior" name="saam.mdlw.srv.aep.aep">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="Binding1" behaviorConfiguration="saam.mdlw.srv.aep.EndBehavior" contract="saam.mdlw.srv.aep.Isrv_aep" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="saam.mdlw.srv.aep.EndBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="saam.mdlw.srv.aep.SerBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
I have a data service up and running, but I'm getting this error:
The remote server returned an error: (413) Request Entity Too Large.
I have tried a number of things to fix this with no luck.
I have set the uploadReadAheadSize on the Web Site and the Data Service in IIS to the max setting.
I have also tried a number of different setups for the config files.
Here is the current app.config for the client:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ILogging" />
<binding name="WCFHttpBinding"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxArrayLength="2147483647"
maxDepth="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WCFWebBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/PSIDataService/PSIWcfDataService.svc"
binding="webHttpBinding" bindingConfiguration="WCFWebBinding"
name="WCFWebBinding" contract="*"/>
</client>
I have tried both bindings, WCFWebBinding and WCFHttpBinding.
Here is the web service web.config.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="WCFHttpBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WCFWebBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/PSIDataService/PSIWcfDataService.svc"
binding="basicHttpBinding"
bindingConfiguration="WCFHttpBinding"
name="WCFHttpBinding"
contract="*"/>
</client>
Again, I have tried both bindings. I don't know what else can be done. Any help would be great.
I have found a solution to this problem. The web.config must have a service added that names the service and has a contract set to "System.Data.Services.IRequestHandler"
<system.serviceModel>
<services>
<service name="PSIDataService.PSIWcfDataService">
<endpoint bindingConfiguration="msgSize"
address=""
binding="webHttpBinding"
contract="System.Data.Services.IRequestHandler"/>
</service>
</services>
My system complained about both the name of the service and the contract (attribute is invalid warnings). The namespace of my service is PSIDataService and the class name is PSIWcfDataService, so I ignored the complaint. The contract name had the same warning. I knew the interface existed, so I ignored that warning, too.
A webHttpBinding is also required.
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ILogging" />
</basicHttpBinding>
<webHttpBinding>
<binding name="msgSize" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>
</webHttpBinding>
</bindings>
I got the idea for this fix from Malvin Ly (malvinly.com/2011/05/09/wcf-data-services-and-maxreceivedmessagesize) So thanks Malvin! I don't like the warnings, but this solved my problem.
I am getting an error: Maximum number of items that can be serialized or deserialized in an object graph is '32767'. Change the object graph or increase the MaxItemsInObjectGraph quota.
Here is what my server-side and client-side web.config looks like:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="App" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="USMC.Playbook.DataService.PlaybookService">
<endpoint address="" behaviorConfiguration="LargeQuotaBehavior" binding="basicHttpBinding"
bindingConfiguration="basicBinding" name="Playbook" contract="USMC.Playbook.DataService.IPlaybookService"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="LargeQuotaBehavior">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization impersonateCallerForAllOperations="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<client>
<endpoint address="http://localhost/AppService.svc" binding="basicHttpBinding" bindingConfiguration="App" contract="AppService.IAppService" name="App"/>
</client>
The request is only pulling items so it shouldnt be throwing an error. Can anyone see what is causing this error?
Put this configuration in your service config,
The thing you have missed in your config is the service behaviour,
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="App" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="USMC.Playbook.DataService.PlaybookService" behaviorConfiguration="SilverlightWCFLargeDataApplication">
<endpoint address="" behaviorConfiguration="LargeQuotaBehavior" binding="basicHttpBinding"
bindingConfiguration="basicBinding" name="Playbook" contract="USMC.Playbook.DataService.IPlaybookService"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="LargeQuotaBehavior">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SilverlightWCFLargeDataApplication">
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization impersonateCallerForAllOperations="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<client>
<endpoint address="http://localhost/AppService.svc" binding="basicHttpBinding" bindingConfiguration="App" contract="AppService.IAppService" name="App"/>
I want to use wshttpbinding (with SSL and without SSL) in single service but it not works, anybody had implemented it. So please guide how can i achieve that?
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="CommonBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceCredentials>
<serviceCertificate findValue="AzilenTechnology" x509FindType="FindBySubjectName" />
</serviceCredentials>
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfig" closeTimeout="00:10:00"
openTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBindingConfig" closeTimeout="00:10:00" openTimeout="00:10:00"
sendTimeout="00:10:00" bypassProxyOnLocal="true" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="CommonBehaviour" name="wcfAllInOne.wcfFileIO">
<endpoint binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<endpoint address="http://localhost:82/WCFAllInOne/wcfFileIO.svc/basicHttpEndPoint" binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingConfig" name="BasicHttp"
contract="wcfAllInOne.IwcfFileIO" />
<endpoint address="http://localhost:82/WCFAllInOne/wcfFileIO.svc/wsHttpBindingEndPoint" binding="wsHttpBinding"
bindingConfiguration="wsHttpBindingConfig" name="wsHttp" contract="wcfAllInOne.IwcfFileIO" />
<endpoint address="https://localhost:444/WCFAllInOne/wcfFileIO.svc/wsHttpSslEndPoint" binding="wsHttpBinding"
bindingConfiguration="wsHttpBindingConfig" name="wsHttpSsl"
contract="wcfAllInOne.IwcfFileIO" />
<endpoint binding="mexHttpsBinding" bindingConfiguration="" contract="IMetadataExchange" />
</service>
</services>
I found the solution, why my last configuration doesn't work,
My first mistake is that i used same configuration for wsHttpBinding with ssl and wsHttpBinding Without SSL
Here in my config file,i had just created only one "wsHttpBindingConfig" for both endpoint (one has http address and another one has https address),
Now i am using two different configuration for to solve this problem.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="CommonBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceCredentials>
<serviceCertificate findValue="AzilenTechnologies" x509FindType="FindBySubjectName" />
</serviceCredentials>
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfig" closeTimeout="00:10:00"
openTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security>
<transport>
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpsBindingConfig" closeTimeout="00:10:00"
openTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="true"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
</security>
</binding>
<binding name="wsHttpBindingConfig" closeTimeout="00:10:00" openTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security>
<transport>
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="CommonBehaviour" name="wcfAllInOne.wcfFileIO">
<endpoint binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<endpoint address="/basicHTTPEndPoint" binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingConfig" name="basicHttp"
contract="wcfAllInOne.IwcfFileIO" />
<endpoint address="/wsHTTPEndPoint" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfig"
name="wsHttp" contract="wcfAllInOne.IwcfFileIO" />
<endpoint address="/wsHTTPSEndPoint" binding="wsHttpBinding"
bindingConfiguration="wsHttpsBindingConfig" name="wsHttpSsl"
contract="wcfAllInOne.IwcfFileIO" />
<endpoint binding="mexHttpsBinding" bindingConfiguration="" contract="IMetadataExchange" />
</service>
</services>