WCF sql dataset Over 50 records will not save - vb.net

Have spent over 20 hrs searching the web and still cant get basichttpbinding to save when
has a number of records (okay when a small number of records)
The service Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false" strict="false" explicit="true" targetFramework="4.0" />
<pages>
<namespaces>
<add namespace="System.Runtime.Serialization" />
<add namespace="System.ServiceModel" />
<add namespace="System.ServiceModel.Web" />
</namespaces>
</pages>
<httpRuntime executionTimeout="600" maxRequestLength="102400"/>
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="IncidentServiceBehavior" name="NewIncidentService_IService">
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="IncidentServiceReference.ServiceClient" />
<endpoint binding="wsHttpBinding" bindingConfiguration="wsHttpBinding_Incident"
name="" contract="IncidentServiceReference.ServiceClient" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<timeouts closeTimeout="01:10:00" />
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="01:10:00"
openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="01:10:00"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxBufferSize="524288" maxReceivedMessageSize="524288" transferMode="Streamed">
<readerQuotas maxDepth="524288" maxStringContentLength="524288"
maxArrayLength="524288" maxBytesPerRead="524288" maxNameTableCharCount="524288" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBinding_Incident" maxReceivedMessageSize="524288"
useDefaultWebProxy="false">
<readerQuotas maxDepth="524288" maxStringContentLength="524288"
maxArrayLength="524288" maxBytesPerRead="524288" maxNameTableCharCount="524288" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="IncidentServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="524288" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647"/>
</requestFiltering>
</security>
</system.webServer>
</configuration>
The client App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
<system.web>
<httpRuntime executionTimeout="600"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService"
maxReceivedMessageSize="524288"
maxBufferSize="524288"
maxBufferPoolSize="524288"
receiveTimeout="01:10:00"
transferMode="Streamed"
sendTimeout="01:10:00"
closeTimeout="01:10:00"
hostNameComparisonMode="StrongWildcard"
openTimeout="01:10:00"
messageEncoding="Text"
textEncoding="utf-8"
allowCookies="false"
bypassProxyOnLocal="false"
useDefaultWebProxy="false">
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="IncidentServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="524288"/>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="---Removed for security-----"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="IncidentServiceReference.IService" name="BasicHttpBinding_IService" behaviorConfiguration="IncidentServiceBehavior" />
</client>
</system.serviceModel>
</configuration>
Has a 413 error - changed to streamed, now get a 400. Error from WCF Test Client
The remote server returned an unexpected response: (400) Bad Request.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IService.saveTasks(saveTasksRequest request)
at ServiceClient.IService.saveTasks(saveTasksRequest request)
Inner Exception:
The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Yes it appears to be a time out, any changes not affect. Have added a timeout in the connectionstring and in IIS 7.0 have added 'serverruntime uploadreadaheadsize="20480000" '
any thoughts would be appreciated
Andrew

May have a solution for this.
Found this
binding name="" openTimeout="00:10:00" closeTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
at this site
http://www.codeproject.com/Questions/481526/Theplusremoteplusserverplusreturnedplusanplusunexp
Needs to before any other basichttpbinding and note that there is no name. I think this set the default values. have set up a test to see if it work and has not failed yet. I will (when time permits) change the values from 2gigs to lower values.
Hope this helps anyone with a similar issue.
Andrew

Related

A binding instance has already been associated to listen URI .after moving from .NET 4.0 to 4.5

After 3 days of never ending search I am posting this. Please help. The following is the config file I have. There is only one endpoint specified , but its saying there is a conflict in the endpoints. Please help me rectifying this conflict.
System.InvalidOperationException: A binding instance has already been
associated to listen URI
'http://dd.myserver.net/MyWebService/MyService'. If two endpoints want
to share the same ListenUri, they must also share the same binding
object instance. The two conflicting endpoints were either specified
in AddServiceEndpoint() calls, in a config file, or a combination of
AddServiceEndpoint() and config.
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
<add key="wcf:webservicehost:enableautomaticendpointscompatability" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
<authentication mode="None"/>
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="MyRESTService.MyService">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" contract="MyRESTService.IMyService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"/>
<security mode="None">
</security>
</binding>
</webHttpBinding>
</bindings>
<protocolMapping>
<add binding="webHttpBinding" scheme="http"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="false"/>
</system.webServer>
</configuration>
Finally I resolved the error given by one guy [https://stackoverflow.com/questions/12643113/wcf-conflicting-endpoints-after-net-4-5-installation/39394010]
I have just removed the security tag inside
before
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"/>
<security mode="None">
</security>
</binding>
</webHttpBinding>
After
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"/>
</binding>
</webHttpBinding>
This little thing took me 3 days of search. thanks to stackoverflow.

Keep getting System.ServiceModel.ServiceActivationException when http binding was removed

I have a WCF based web api running on windows server 2012 iis.
and I've recently trying to remove the http and suddenly I got System.ServiceModel.ServiceActivationException error. If I add http binding back, it works again.
How can I fix it so that I can run it on https only? Thanks for helping!
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="appveripad" value="xx"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2147483647" executionTimeout="3600" useFullyQualifiedRedirectUrl="true" />
<customErrors mode="Off" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name=""
transferMode="Buffered"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
defaultOutgoingResponseFormat="Json"
helpEnabled="true"
automaticFormatSelectionEnabled="true">
<readerQuotas maxDepth="64"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647"
maxBytesPerRead="2147483647"
maxArrayLength="2147483647" />
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
It turns out that the structure of web.conf for WCF has changed and been simplified a great deal.
I've fixed it myself by examine the exact windows log error in Event Viewer/Windows logs/Application.
The error message wrote
cannot be activated due to an exception during compilation. The exception message is: An endpoint reference cycle was detected in your configuration. The following reference cycle must be removed: webHttpEndpoint/, webHttpEndpoint/. (C:\inetpub\wwwroot\xxx\web.config line 111). --->
...
Process Name: w3wp
Process ID: 10396
And then I realized that I must remove now redundant endpoints that I have in the web.config file.
Below is the corrected part of the web.config that enables the https binding in the IIS. With and/or without http binding, it works. The only thing I did is I removed the endpoints and I added bindings sections.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
<binding name="SecureTransport" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>

transfert large file with wcf service

I want to run a WCF service file transfer
my problem is when sending a large file, I get this exception message ProtocolException
(413) Request Entity Too Large.
this is my configuration
I found this code on the internet, so I'm not sure that it works
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="999999" maxRequestLength="2097151" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="BasicHttpBinding_ITransferService">
<endpoint
binding="basicHttpBinding" contract="ITransferService"
bindingConfiguration="BasicHttpBinding_ITransferService" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITransferService" closeTimeout="04:01:00"
openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01: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" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
I'd try to send a file part by part.
Your API could be sth like this:
byte[] GetFile (string FileID, int startByte, int bytes, ...)
That way you can easily resume transfer after error, you don't need to worry about timeouts, etc.

WCF File Upload Large File

I've been doing a fair bit of research over the last two days to find a solution to my problem but to no avail.
I have created a WCF service like so:
[OperationContract]
void CopyMemberFile(string memberNumber, string fileName, byte[] fileBytes);
And I call it from my client like so from a page_load event:
byte[] filebytes = null;
using (Stream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
{
filebytes = new byte[fs.Length];
fs.Read(filebytes, (int)0, (int)fs.Length);
}
client.CopyMemberFile(memberNumber, Path.GetFileName(file), filebytes);
My configuration is like so:
Client Config:
<configuration>
<system.web>
<authorization>
<allow users="*"/>
</authorization>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="300" cookieless="UseUri" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<properties>
<add name="FirstName"/>
<add name="LastName"/>
<add name="MemberNumber"/>
<add name="LastVisit" type="System.DateTime"/>
</properties>
<providers>
<clear />
<add name="AspNetSqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="ApplicationServices"
applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="ApplicationServices"
applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider"
applicationName="/" />
</providers>
</roleManager>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory" />
<add path="Telerik.Web.UI.WebResource.axd"
type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
</httpHandlers>
<httpRuntime maxRequestLength="1048576"/>
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="online.members.asp.Services.MembersOnlineSeviceAjaxAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="online.members.asp.Services.MembersOnlineSeviceAjax">
<endpoint address="" behaviorConfiguration="online.members.asp.Services.MembersOnlineSeviceAjaxAspNetAjaxBehavior"
binding="webHttpBinding"
contract="online.members.asp.Services.MembersOnlineSeviceAjax" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMembershipApplications"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<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>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:58119/MembershipApplications.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMembershipApplications"
contract="MembershipApplicationsServiceReference.IMembershipApplications"
name="BasicHttpBinding_IMembershipApplications" />
</client>
</system.serviceModel>
Service Config:
<configuration>
<system.web>
<roleManager enabled="true" />
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
The error I'm getting is this:
3/02/2013 11:12:39 AM: Upload.aspx Error: The remote server returned an unexpect
ed response: (400) Bad Request.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResp
onse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factor
y, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha
nnelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeS
pan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message messag
e, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim
eout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall
Message methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
at online.members.asp.MembershipApplicationsServiceReference.IMembershipAppli
cations.CopyMemberFile(String memberNumber, String fileName, Byte[] fileBytes)`
I can upload files at only a few KB each but any larger than say 8KB and thing just fails
Any help would be fantastic.
Calling code:
protected void Page_Load(object sender, EventArgs e)
{
var file = Request.Form["name"];
var memberNumber = Request.Form["memberNumber"];
var tempId = Guid.NewGuid();
var client = new MembershipApplicationsServiceReference.MembershipApplicationsClient();
client.LogEvent("Entered Upload.aspx");
try
{
byte[] filebytes = null;
using (Stream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
{
filebytes = new byte[fs.Length];
fs.Read(filebytes, (int)0, (int)fs.Length);
client.LogEvent("Starting service call from Upload.aspx");
client.CopyMemberFile(memberNumber, Path.GetFileName(file), filebytes);
}
client.LogEvent("Completed service call from Upload.aspx");
}
catch (Exception ex)
{
Debug.WriteLine(ex.StackTrace);
client.LogEvent("Upload.aspx Error: " + ex.Message + ex.StackTrace);
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
finally
{
client.LogEvent("Finishing up");
}
}
Looking at your service's config file, you're using .NET 4.0 and you're not specifying any binding, so you're going to receive the default settings for basicHttpBinding. As suggested in the comments above, update your config file for your service like this:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMembershipApplications"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false"
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Text"
textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<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>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="YourServiceName">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMembershipApplications"
contract="YourFullyQualifiedContractName" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
This will tell WCF to use your settings for the basicHttpBinding rather than the .NET defaults.
Alternatively, you can omit the name attribute on the binding definition and WCF will use it as the default binding for all services handled by the config file (if you have more than one).
If that doesn't help, or if you're getting a different error now, let us know and we'll take it from there.

I can't upload files larger than 45 KB using wcf

My code works perfect for files smaller than 45 Kb but when I upload files large files I get that error:
The remote server returned an error: (400) Bad Request.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (400) Bad Request.
Source Error:
Line 120: [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
Line 121: WebApplication2.ServiceReference1.uploadfileResponse WebApplication2.ServiceReference1.IService1.uploadfile(WebApplication2.ServiceReference1.RemoteFileInfo request) {
Line 122: return base.Channel.uploadfile(request);
Line 123: }
Line 124:
Source File: C:\Users\KHALED\documents\visual studio 2010\Projects\WcfServicefiles\WebApplication2\Service References\ServiceReference1\Reference.cs
Line: 122
Stack Trace:
[WebException: The remote server returned an error: (400) Bad Request.]
System.Net.HttpWebRequest.GetResponse() +6115427
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +48
[ProtocolException: The remote server returned an unexpected response: (400) Bad Request.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9455983
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345
WebApplication2.ServiceReference1.IService1.uploadfile(RemoteFileInfo request) +0
WebApplication2.ServiceReference1.Service1Client.WebApplication2.ServiceReference1.IService1.uploadfile(RemoteFileInfo request) in C:\Users\KHALED\documents\visual studio 2010\Projects\WcfServicefiles\WebApplication2\Service References\ServiceReference1\Reference.cs:122
WebApplication2._Default.Button2_Click(Object sender, EventArgs e) in C:\Users\KHALED\documents\visual studio 2010\Projects\WcfServicefiles\WebApplication2\Default.aspx.cs:38
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
This is my webconfig code for the server:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime maxRequestLength="2097151"
useFullyQualifiedRedirectUrl="true"
executionTimeout="14400"
/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SomeServiceServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="Service1"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647" transferMode="Streamed">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="None">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Service1.svc.cs" >
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="Service1"
contract="IService1" >
</endpoint>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
And this the web.config for the client
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime maxRequestLength="2097150" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SomeServiceServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SomeServiceServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="04:01:00"
openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
useDefaultWebProxy="true">
<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>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/WcfServicefiles/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
The below section of your servers web.config
<services>
<service name="Service1.svc.cs" >
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="Service1"
contract="IService1" >
</endpoint>
</service>
</services>
has some values for attributes that are wrong. The value for the name attribute of service element needs to be namespace.Service1 and similarly the contract attribute value of endpoint element needs to be namespace.IService1 as shown below:
<services>
<service name="<namespace>.Service1" >
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="Service1"
contract="<namespace>.IService1" >
</endpoint>
</service>
</services>
Just replace with the namespace of Service1 class. And that should work
Try follwing this example: http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP