C# – Getting System.ServiceModel.ProtocolException while Consuming WCF Webservice

asp.netcwcfweb services

I am consuming a WCF web service to which i have no control in web service side.

I have given a auto generated svc.cs proxy file by which i am consuming it.

Actually i am requesting to the web service to download some large data from client side.

Sometimes i am getting

System.ServiceModel.ProtocolException

in my Client side.

Exception is as follow:

System.ServiceModel.ProtocolException: The number of bytes available
is inconsistent with the HTTP Content-Length header. There may have
been a network error or the client may be sending invalid requests.

Server stack trace: at
System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream
inputStream) at
System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception&
requestException) at
System.ServiceModel.Channels.HttpChannelFactory.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.ServiceChannel.Call(String action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs) 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 IBulkDataSvc.GetEmployeesData(String
BusinessPath, DateTime EffectiveDate, String TerminalName) at
Empower.ServiceRequest.EmployeeDataXML(DateTime time, String terminal)
at Empower.Empower.DownloadEmployeeList(String terminalName)

My web service binding config in client side is as follow(only showing bindings),

    <bindings>
      <basicHttpBinding>
        <binding name="BulkDataSvcSoap">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Basic" />
          </security>
        </binding>
        <binding name="BulkDataSvcHttpsSoap">
          <security mode="Transport">
            <transport clientCredentialType="Basic" />
          </security>
        </binding>
      </basicHttpBinding>
      <netTcpBinding>
        <binding name="BulkDataSvcTcp">
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>

I am little bit of confused from which end it is really generated and why it is generating?

I have googled and did not fine anything much helpful.So can some one please help me out from this puzzle
.

Best Answer

Have you got a chance to read this calling non wcf service

Also, in some cases iF your request is bringing data larger than what is specified at webservice side then you are bound to get this.

Related Topic