Cant send large data to WCF server - wcf

i am failing sending large data to wcf server, despite i configured it.
sending small data works ok.
the data is a TimeSpan, GUID, int, bool, string. when the string.Length is larger then about 45000 - it fails
in my server config:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWcfService"
maxBufferSize="1048576000"
maxBufferPoolSize="524288000"
maxReceivedMessageSize="1048576000">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Receiver.StorageHandlerService">
<endpoint address="" binding="basicHttpBinding" contract="Receiver.ISorageHandlerService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://99.99.99.99:8733/Design_Time_Addresses/Receiver/StorageHandlerService/"/>
</baseAddresses>
</host>
</service>
</services>
in my client config:
bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISorageHandlerService"
maxBufferSize="1048576000"
maxBufferPoolSize="524288000"
maxReceivedMessageSize="1048576000">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://99.99.99.99:8733/Design_Time_Addresses/Receiver/StorageHandlerService/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISorageHandlerService"
contract="ServiceData.ISorageHandlerService" name="BasicHttpBinding_ISorageHandlerService" />
</client>
thanks!

While you have configured a binding with larger than default values in your service configuration, it's not being used because it's not assigned to an endpoint. To assign the binding configuration you've specified, you need to use the bindingCongfiguration attribute on the endpoint element in your service configuration (similar to the way the client configuration is set up), like this:
<services>
<service name="Receiver.StorageHandlerService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IWcfService"
contract="Receiver.ISorageHandlerService">
Your configuration as posted did not specify a configuration for the basicHttpBinding, so a default instance of BasicHttpBinding is used, with the default values for the various settings.

Related

WCF Service error "Maximum message size quota for incoming message as been exceeded"

I have a WCF Service library project who request a large recordset from a database and returns it. This error pop everytime in the WCF Test Client. I changed the MaxReceivedMessageSize to a large value but it doesn't seem to take it. Here the Web.Config
<client>
<endpoint address="http://localhost:8000/SAPIntranet" binding="basicHttpBinding"
bindingConfiguration="Binding_SAPIntranet" contract="SAPIntranet"
name="SAPIntranet" kind="" endpointConfiguration="" />
</client>
<bindings>
<basicHttpBinding>
<binding name="Binding_SAPIntranet" openTimeout="00:02:00" maxBufferPoolSize="20000000"
maxBufferSize="20000000" maxReceivedMessageSize="20000000">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
Error message always gives the default value (65535).
I guess there is something I'm doing wrong, but can't figure it out.
Thanks for your time and help
MaxReceivedMessageSize setting takes effect on the server-side, we should apply the binding configuration on the service endpoint. The above configuration applies only to the client service endpoint. Please refer to the below service configuration.
<services>
<service name="WcfService1.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="mybinding" contract="WcfService1.IService1">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="mybinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
Feel free to let me know if there is anything I can help with.

The remote server returned an unexpected response: (400) Bad Request. if the transferring string size is more than 48KB

i have a self hosted wcf service, below are the config details of both service and client, it works fine if the transferred string/data size is less than 48KB but if the size is more then it throws the title error.
i am new to wcf and searched this issue, found many earlier reports which ask to configure the buffer size but its not working in my case.
Thanks.
Server config details
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_DeployConfiguration" transferMode="Streamed" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" receiveTimeout="00:30:00" sendTimeout="00:30:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None"></security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="Default" name="CPConfigDeploy.DeployConfiguration">
<endpoint address=""
binding="basicHttpBinding"
contract="CPConfigDeploy.IDeployConfiguration"/>
</service>
</services>
</system.serviceModel>
and below is the client config details
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_DeployConfiguration" transferMode="Streamed" maxReceivedMessageSize="21474836480" maxBufferPoolSize="21474836480" maxBufferSize="10485760" receiveTimeout="00:30:00" sendTimeout="00:30:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://10.140.188.117:8080/deploy" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_DeployConfiguration"
contract="IDeployConfiguration" name="BasicHttpBinding_IDeployConfiguration"/>
</client>
</system.serviceModel>
You don't assign the binding configuration you defined to the service endpoint. In your service's config you have:
<endpoint address=""
binding="basicHttpBinding"
contract="CPConfigDeploy.IDeployConfiguration"/>
Since there's no bindingConfiguration value set, the system uses the default values for basicHttpBinding.
What you need is this:
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding_DeployConfiguration"
contract="CPConfigDeploy.IDeployConfiguration"/>
Then your service will pick up the larger values you specified for the binding configuration.

WCF Service with security mode none

My WCF service works fine with Security Mode="Transport" and clientCredentialType="Windows" (with client and service on either one machine or two). But I need to put the service on the other side of a firewall where Windows Authentication is not possible. I know I can either install X.509 certs or use security="None" (to which I would add my own security protocol). But I cannot get "None" to work! I keep getting 'The socket connection was aborted' error.
Here is the config, please let me know if you spot anything. I have tried it without the 2 lines that specify clientCredentialType="none" but it makes no diff. P.S. Each time I make a config change I stop and restart both the client and the service.
SERVER CONFIG
<system.serviceModel>
<services>
<service name="OuterService.OutCardTrx">
<endpoint address="" binding="netTcpBinding" contract="OuterService.IOutCardTrx">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://jimt4.campus.internal:8081/PCIOutService"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="netTcpBinding">
<security mode="None" >
<transport clientCredentialType="None" />
<message clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
CLIENT CONFIG:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IOutCardTrx" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="None" />
<message clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://jimt4.campus.internal:8081/" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IOutCardTrx" contract="OCS.IOutCardTrx"
name="NetTcpBinding_IOutCardTrx">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Not 100% sure this is the reason, but your binding security settings don't match between the client and the service.
Note that the default security for NetTcpBinding is Transport (for mode). You define None in your binding in the service config, but that binding is never assigned to the service endpoint, so your service is using the default settings for NetTcp.
On the other hand, you are setting the binding configuration on your client.
Try setting the binding configuration in your service endpoint like this:
<endpoint address="" binding="netTcpBinding"
bindingConfiguration="netTcpBinding"
contract="OuterService.IOutCardTrx">
This will assign your specified binding to the endpoint, with security set to "None". I would also recommend changing the binding configuration name to something other than "netTcpBinding" to avoid any possible confusion.
Did you try increasing the values for MaxItemsInObjectGraph, MaxReceivedMessageSize, MaxBufferPoolSize, MaxBufferSize, MaxArrayLength in both client/server configs? The default values are pretty low, try maxing them out to 2147483647.
Also try enabling tracing on the service to see further error details.

WCF method call returning web service disco page

I have a WCF web service and application that works fine in developemnt. I've published the WCF on an IIS Server and am able to use it from the web app inside the firewall addressing it by server name. HOWEVER, now that I've put it out for use externally, it is causing problems.
My web app is getting an error trying to connect. I can see the service, disco, wsdl, etc from inside and outside the firewall, but when I make my first call for authentication from the outside, the service is returning the DISCO page instead of processing the authentication method call. This results in a ProtocolException because as I understand it, the app is expecting xml, not html.
Again, exact same web app works fine interally hitting the IIS server.
One difference being externally I'm getting to it from a web address, internally i'm using the server name. But the service loads in a web browser outside the firewall using the web address.
Partial web app config:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding
name="WSHttpBinding_IWebService"
closeTimeout="00:03:00"
openTimeout="00:03:00"
receiveTimeout="00:10:00"
sendTimeout="00:03:00"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="5000000"
maxReceivedMessageSize="5000000"
useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="5000000"
maxArrayLength="5000000"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport
clientCredentialType="Windows"
proxyCredentialType="None"
realm="" />
<message
clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default"
establishSecurityContext="true"
/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://<dns address/server address>/WebService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IWebService"
contract="WebServiceRef.IWebService" name="WSHttpBinding_IWebService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</client>
Partial service web.config file:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding
name="ServiceBinding"
openTimeout="00:03:00"
sendTimeout="00:03:00"
transactionFlow="false"
maxBufferPoolSize="5000000"
maxReceivedMessageSize="5000000">
</binding>
</wsHttpBinding>
</bindings>
<services>
<service
behaviorConfiguration="xxx.WebServiceBehavior"
name="xxx.WebService">
<endpoint
address="http://<dns address/server address>/WebService.svc"
binding="wsHttpBinding"
bindingConfiguration="ServiceBinding"
contract="xxx.IWebService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
/WebService.svc"/>

WCF Multiple Service Configuration Issue

Scenario
Ignoring that fact that some of the settings might be wrong and inconsistent or just not there!.
Why does the program fail to compile when I try and put these 2 separate configurations for WCF Services into the same APP.CONFIG file? One was writen by myself and another by a friend, yet I cannot get the application to compile. What have I missed?
ERROR
Type Initialization Exception
CODE
<configuration>
<system.serviceModel>
<!--START Service 1 CONFIGURATION-->
<bindings>
<netTcpBinding>
<binding name="tcpServiceEndPoint" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:05:00"
enabled="true" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address=""
binding="netTcpBinding" bindingConfiguration="tcpServiceEndPoint"
contract="ListenerService.IListenerService"
name="tcpServiceEndPoint" />
</client>
<!--END Service 1 CONFIGURATION-->
<!--START Service 2 CONFIGURATION-->
<services>
<service name="UploadObjects.ResponseService">
<!-- Define NetMsmqEndpoint -->
<endpoint address=""
binding="netTcpBinding"
contract="UploadObjects.IResponseService"
bindingConfiguration="TransactedBinding"/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="TransactedBinding">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<!--END Service 2 CONFIGURATION-->
</system.serviceModel>
</configuration>
A couple of observations:
Your <client> endpoint has no address:
<client>
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="tcpServiceEndPoint"
contract="ListenerService.IListenerService"
name="tcpServiceEndPoint" />
How do you expect your client code to know where to connect to?? You need to specify a full WCF service address in any client <endpoint>
Your <service> endpoint also is lacking an address - you either need to specify a full address here, or than you have to have a base address defined in your service! One of the two must be present:
<services>
<service name="UploadObjects.ResponseService">
<endpoint address="net.tcp://YourServer:5455/YourServiceAddress"
binding="netTcpBinding"
contract="UploadObjects.IResponseService"
bindingConfiguration="TransactedBinding"/>
</service>
or:
<services>
<service name="UploadObjects.ResponseService">
<endpoint address=""
binding="netTcpBinding"
contract="UploadObjects.IResponseService"
bindingConfiguration="TransactedBinding"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://YourServer:5455/YourServiceAddress" />
</baseAddresses>
</host>
</service>
Also, from your question, it's not clear what you're trying to do when you get the error:
are you trying to start up a service host that hosts the service? A console app, or IIS?
are you trying to connect a client side to a running service?