WCF to receive large strings, get exception - wcf

I went through all the posts about this, nothing helped, so I posted this because I'm pulling my hair out.
I have a WCF web-service that has a method that receives a string, a long string. It works with a string of 2,390,158 characters (tried it) but won't work with a string of about 5,440,519 characters. (I'm using VS 2010)
I have this error:
System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response http:// localhost : 58014/ WSWebService.asmx. The reason may be that the connection endpoint service does not use the HTTP protocol. This may also be due to a HTTP request context has been ignored by the server (possibly due to the discontinuation of service).
I put all parameters I could at int.MaxValue (2,147,483,647) but it still won't work. Any help/suggestion is gladly appreciated.
I removed the "timeout" parts but it makes no difference :
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
Here's the binding in my app.config:
<bindings>
<basicHttpBinding>
<binding name="WSWebServiceSoap" maxReceivedMessageSize="20971520"
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>
My config server side is :
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WSWebServiceSoap" maxReceivedMessageSize="20971520"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
maxBufferSize="20971520" maxBufferPoolSize="20971520"
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>
</system.serviceModel>
So yes, same configuration. Am I missing something?

Service was ASMX based, redone it pure WCF and now it works.

Related

Service sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details

I am using one WCF service that deployed in server designed in .net 4.0v . But after processing all queues it is generating exception i.e. service sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. I am using "wsHttpBinding"
<customBinding>
<binding name="CustomSecurity">
<security>
<localServiceSettings maxPendingSessions="1000" />
<secureConversationBootstrap />
</security>
</binding>
</customBinding>
<binding name="CustomSecurityxxx" closeTimeout="01:00:00"
openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="1000000" maxReceivedMessageSize="1000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="01:00:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
Thanks in advance. Can anyone help me to solve this problem.
Yes it is fixed.
I increased the serviceThrottling values
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000"/> from 200 and simply enclosed the service instances in using block so that the block will handle the scope of the object like initializing and disposing
Sample code syntax is as follows
xxxClient ServiceObject;
using (ServiceObject= new xxxClient())
{
try
{
your code goes here
}
catch (Exception ex)
{
ServiceObject.Abort();
}
}
Hope it will help to those facing the same problem.

CredentialCache.DefaultNetworkCredentials empty when using TransportWithMessageCredential

I'm currently trying to use TransportWithMessageCredentials and https on my wcf project. I have set both the client and the server security mode="TransportWithMessageCredential" and the clientCredentialType="Windows".
When I go to get the credentials from CredentialCache.DefaultNetworkCredentials, the username, password and domain are all empty.
Any reason why these would be empty? If they will always be empty, where would I get the credentials to pass?
How would I pass the logged in user credentials to the service without prompting them for a login?
Client binding
<basicHttpBinding>
<binding name="ClientHttpEndpoint" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:02:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="4194304" maxBufferPoolSize="524288" maxReceivedMessageSize="4194304"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
Server binding
<basicHttpBinding>
<binding name="WindowsTransportCredentialBinding" maxBufferSize="524288"maxReceivedMessageSize="524288">
<readerQuotas maxDepth="128" maxStringContentLength="1048576" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
...
<service name="Test.DiagnosticService">
<endpoint binding="basicHttpBinding" bindingConfiguration="WindowsTransportCredentialBinding" name="ClientDiagnosticEndpoint" contract="Test.IDiagnostic" />
</service>
Code to set the username and password
ChannelFactory<IDiagnostic> test = new ChannelFactory<IDiagnostic>(DIAGNOSTIC_ENDPOINT_NAME);
test.Credentials.UserName.UserName = "TestUser";
test.Credentials.UserName.Password = "User";
return test.CreateChannel();
The ICredentials instance returned by DefaultCredentials cannot be used to view the user name, password, or domain of the current security context.
http://msdn.microsoft.com/en-us/library/system.net.credentialcache.defaultcredentials%28v=vs.90%29.aspx

Getting The remote server returned an unexpected response: (400) Bad Request exception while calling WCF

I am trying to call WCF method from my MVC application. While calling the WCF method, I am getting the "The remote server returned an unexpected response: (400) Bad Request" error.
I am passing a list of items. if I am passing only 50, its going in, but if its morethan that, it is showing the error message.
Any help on this will be greatly appreciated.
My client config:
<basicHttpBinding>
<binding name="BasicHttpBinding_IPaymentRequestService"
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="StreamedRequest"
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>
Server Config:
<services>
<service name="BasicHttpBinding_IPaymentRequestService" >
<endpoint name="BasicEndpoint"
address="http://localhost/Intel.IIP.WCF.Hosting/PaymentRequestServiceHost.svc"
binding="basicHttpBinding" bindingConfiguration="ServiceBinding"
contract="IPaymentRequestService">
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding >
<binding name="ServiceBinding"
transferMode="StreamedRequest" allowCookies="false" useDefaultWebProxy="true"
messageEncoding="Text" hostNameComparisonMode="StrongWildcard"
bypassProxyOnLocal="false" maxBufferPoolSize="2147483647" textEncoding="utf-8"
closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas
maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxDepth="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="None" ></security>
</binding>
</basicHttpBinding>
</bindings>
Regards
Amal
Did you try:
<system.web>
<httpRuntime maxRequestLength="2097151" />
</system.web>

WCF <413> Request Entity Too Large. </br> The remote server returned an error: <412> Request Entity Too Large

WCF Streaming transfer mode hosted on IIS and trying to send 2 MB file from a console application but it fails with this error. It works on 3 different servers and NOT one prod server where as all three share the same information.
Is it anything related to SSL on IIS ? what might be problem ?
how to set UploadReadAheadSize Metabase Property in IIS 7.0 ?
IIS 7
Windows Server 2008 64 bit
Client:
<basicHttpBinding>
<binding name="BasicHttpBinding_IFileStreamingService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:05:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed"
useDefaultWebProxy="true">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
Service:
<basicHttpBinding>
<binding name="HttpStreaming" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" messageEncoding="Mtom">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<!--<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>-->
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>

Silverlight windows authentication and running fiddler

I'm using WindowsAuthentication in my silverlight application
Here is the setting that I have done in web.config
<authentication mode="Windows"/>
<basicHttpBinding>
<binding name="ServiceBinding" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
it's working fine ,but when ever i run fiddler, the application asks for the username and password! Does any one knows what is the reason behind that.
Thank you,
Naseem
In fiddler beta 2, there is a option "use proxy credentials".
Or you can customize the fiddler rule for your development server using:
if (oSession.HostnameIs("www.example.com")){
oSession.bypassGateway = true;
}
here is the link how to do it:
http://www.fiddler2.com/fiddler/dev/scriptsamples.asp