I have a WCF service with a basicHttp binding hosted on II7 being called from a Silverlight client. I can call all of the services on the endpoint without issue
except for one.
I’m trying to upload a file so the service receives a byte array. If I upload files over 3MB in size, I get the error below.
When I try calling this service:
[OperationContract]
public AuditResponse UploadVendorAuditFile( int vendorID,
int sourceSystemID,
string fileName,
byte[] fileBytes )
{
// stuff
}
I get the following error:
401 – Unauthorized: Access is denied due to invalid credentials. You
do not have permission to view this directory or page using the
credentials that you supplied.
Here are my configurations.
Endpoint Binding
<basicHttpBinding>
<binding
name="basicHttpBindingConfiguration"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
>
<readerQuotas
maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"
/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
</security>
</binding>
</basicHttpBinding>
Service Configuration
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
Client
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding
name="BasicHttpBinding_WMService"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
>
<security mode="TransportCredentialOnly" />
</binding>
</basicHttpBinding>
</bindings>
Are the files for which it fails are bigger in size say greater than 1MB or so? Try enabling tracing to know the actual cause of the error.
If the files are of larger size then it might be cause of the reader quota settings which need to be set for larger values on both server and client side
Also consider adding the maxItemsInObjectGraph in your serviceBehaviour as shown
NOTE: Make sure to have the same readerQuotas settings on both client and server side
Also try to set the below setting in your web.config