How do I setup config files for WCF Data Service (odata) with EF 6 - wcf

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.

Related

The maximum message size quota for incoming messages has been exceeded

I would like to ask for your help because sometimes I get an error message when I call a service : 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.
On one side :
<bindings>
<basicHttpBinding>
<binding name="BasicHttp" bypassProxyOnLocal="true"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WebHttp" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://xxx:7575/MyRequest.svc" behaviorConfiguration="webhttp"
binding="webHttpBinding" bindingConfiguration="WebHttp"
contract="MyService.Service.Contract.IRequestService" name="MyServiceEndpoint" />
</client>
on the other side (xxx) :
<system.serviceModel>
<services>
<service name="MyService.Service.RequestService" behaviorConfiguration="ServiceEndpointBehavior">
<endpoint address="" binding="webHttpBinding" contract="MyService.Service.Contract.IRequestService" behaviorConfiguration="RestEndPointBehavior" bindingConfiguration="WebHttp"/>
</service>
</services>
<bindings>
<basicHttpBinding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WebHttp" allowCookies="true" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="32" maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
Jojo
I tried several things following the different topics with the same error on "stackoverflow" but nothing works. Thanks in advance
As far as I know, if increasing this value alone doesn't work you may also increase the value of httpRuntime.
If this doesn't work, try BasicHttpBinding.

Upload greater than 8 MB streams through WCF Service

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.

wcf The provided URI scheme 'http' is invalid; expected 'https'

im tring to create fileTransfer base on this post
when i test it on local it work great
i set my service on the server using iis without ssl
this is my server config:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
<bindings>
<wsHttpBinding>
<binding name="TransferService" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="TransferServiceBehavior" name="WcfFTP.FtpService">
<endpoint address="FtpService.svc" binding="wsHttpBinding" bindingConfiguration="TransferService" contract="WcfFTP.IFileTransfer"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TransferServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500"/>
</behavior>
</serviceBehaviors>
</behaviors>
and thats my client:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IFileTransfer" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Digest" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://www.myhost.com/WsFTP/FtpService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IFileTransfer"
contract="FtpWcfClient.IFileTransfer" name="WSHttpBinding_IFileTransfer" />
</client>
iv been tring some help on the net with this security issue but this error seems to be strang
You binding configuration for client and server are incompatible. The server specifies no security but the client specifies TransportWithMessageCredential. Can you set security mode in client config to None.
I strongly suggest you to use WCF configuration editor too, which save you against many common mistakes such as misspellings, mismatch binding etc.

Issue on max readers quotas in WCF web service

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:GetFileResult. The InnerException message was 'There was an error deserializing the object of type WindowsClient.CloudServiceProxy.GetFileResponse. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 41572.'. Please see InnerException for more details.
I am getting this issue the
sever web.config is
<system.serviceModel>
<services>
<service behaviorConfigura
tion="CloudServiceBehaviour" name="Web.CloudService">
<endpoint name="CloudServiceClientEndPoint" bindingConfiguration="CloudBindingConfig" address="http://localhost:53243/CloudService.svc" binding="wsHttpBinding" contract="Web.ICloudService"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CloudServiceBehaviour">
<serviceMetadata httpGetEnabled="True" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="CloudBindingConfig" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="200" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
and the client web.config is ,
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="CloudServiceClientEndPoint" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:30:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:53243/CloudService.svc" binding="wsHttpBinding"
contract="CloudServiceProxy.ICloudService" name="CloudServiceClientEndPoint" />
</client>
</system.serviceModel>
Since the error is while deserializing the GetFileResponse object, that tells you the problem is in the client-side stack.
Your client side binding is using the default configuration for wsHttpBinding because you have omitted to specify the bindingConfiguration name on the endpoint. Try adding bindingConfiguration="CloudServiceClientEndPoint" to the endpoint element and then your large values for the readerQuotas settings will be picked up.

WCF Custom binding - send timeout always reached

I have a wcf service that needs to implement callbacks and be hosted on IIS 6.0. Since IIS 6.0 doesn't support the net.tcp binding, I decided to use a custom binding because the service is accessed by different clients in different timezones and, using custom binding, I can set the allowed clock skew time to values other than the default one.
Here is my server config file:
<bindings>
<customBinding>
<binding name="pscNetBinding" openTimeout="00:10:00">
<reliableSession acknowledgementInterval="00:00:00.2000000"
flowControlEnabled="true" inactivityTimeout="23:59:59"
maxPendingChannels="128" maxRetryCount="8" maxTransferWindowSize="128"
ordered="true" />
<compositeDuplex />
<oneWay maxAcceptedChannels="128" packetRoutable="false">
<channelPoolSettings idleTimeout="00:10:00"
leaseTimeout="00:10:00" maxOutboundChannelsPerEndpoint="10" />
</oneWay>
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Default" writeEncoding="utf-8">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport manualAddressing="false"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="2147483647"
proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered"
unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true"/>
</binding>
</customBinding>
</bindings>
<services>
<service name="SchneiderElectric.PSCNet.Server.Services.PSCNetWCFService" behaviorConfiguration="Behaviors1">
<host>
<baseAddresses>
<add baseAddress ="http://10.155.18.18:2000/PSCNet"/>
</baseAddresses>
</host>
<endpoint address="" binding="customBinding" bindingConfiguration="pscNetBinding"
contract="SchneiderElectric.PSCNet.Server.Contracts.IPSCNetWCFService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Behaviors1">
<serviceMetadata httpGetEnabled = "true"/>
<!--<serviceThrottling maxConcurrentCalls="2048" maxConcurrentSessions="2048" maxConcurrentInstances="2048" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />-->
</behavior>
</serviceBehaviors>
</behaviors>
Client config file:
<bindings>
<customBinding>
<binding name="pscNetBinding" openTimeout="00:10:00">
<reliableSession acknowledgementInterval="00:00:00.2000000"
flowControlEnabled="true" inactivityTimeout="23:59:59"
maxPendingChannels="128" maxRetryCount="8" maxTransferWindowSize="128"
ordered="true" />
<compositeDuplex />
<oneWay maxAcceptedChannels="128" packetRoutable="false">
<channelPoolSettings idleTimeout="00:10:00"
leaseTimeout="00:10:00" maxOutboundChannelsPerEndpoint="10" />
</oneWay>
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Default" writeEncoding="utf-8" >
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding >
<httpTransport manualAddressing="false"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="2147483647"
proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered"
unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://10.155.18.18:2000/PSCNet" binding="customBinding"
bindingConfiguration="pscNetBinding" contract="PSCNetWCFService.IPSCNetWCFService"
name="pscNetBinding" />
</client>
If I use the server and client on the same machine, everything works fine. If I run them on different machines, I get the following error:
Could not connect to
http://10.155.18.198:9000/e60ba5b3-f979-4922-b9f8-c820caaa04c2. TCP
error code 10060: A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond
10.155.18.198:9000.
Can anyone in the community help me in this regard?
Can you show the part of the config where you're defining the customBinding? Maybe you just didn't paste that part in, but when you define a custom binding, you have to specify an encoding and a transport at minimum - something like this:
<bindings>
<customBinding>
<binding name="MyCustomTextTcpBinding">
<textMessageEncoding />
<tcpTransport />
</binding>
</customBinding>
</bindings>
Can you also paste in the part where you're defining your "pscNetBinding" bindingConfiguration?
Windows service is undoubtely a nice solution but i think a better would be a self hosting
and you could have anytype of binding on it.