CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Posts
    18

    Question WCF + DataTable in OperationContract = Exception on client side

    My WCF:
    Code:
        [ServiceContract]
        public interface IWorkbookService
        {
            [OperationContract]
            DataTable GetDownpayments(KeyValuePair<int, string> sgm);
        }
    
        class WorkbookService : IWorkbookService
        {
            public DataTable GetDownpayments(KeyValuePair<int, string> sgm)
            {
                /// works fine, no exceptions here
                return Common.GetDownpayments(selectedSegment);
            }
        }

    AS soon as I invoke GetDownpayments() on client side I get:

    System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:02:59.8430000'. ---> System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:02:59.8430000'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
    at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
    at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
    --- End of inner exception stack trace ---
    at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
    at System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
    at System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
    at System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout)
    at System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
    at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
    at System.Net.Security.NegotiateStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
    at System.Net.Security.NegotiateStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
    at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
    --- End of inner exception stack trace ---
    at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
    at System.Net.Security.NegotiateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
    at System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
    --- End of inner exception stack trace ---

    Server stack trace:
    at System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
    at System.ServiceModel.Channels.SessionConnectionReader.Receive(TimeSpan timeout)
    at System.ServiceModel.Channels.SynchronizedMessageSource.Receive(TimeSpan timeout)
    at System.ServiceModel.Channels.FramingDuplexSessionChannel.Receive(TimeSpan timeout)
    at System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceive(TimeSpan timeout, Message& message)
    at System.ServiceModel.Dispatcher.DuplexChannelBinder.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 DSSIP_Test.ServiceReference1.IWorkbookService.GetDownpayments(KeyValuePair`2 selectedSegment)
    at DSSIP_Test.ServiceReference1.WorkbookServiceClient.GetDownpayments(KeyValuePair`2 selectedSegment) in C:\PRJ\DSSIP_Test\Service References\ServiceReference1\Reference.cs:line 205
    There's nothing wrong with timeout, that's fo sure. Table to be returned is rather small - about 10 rows with 20 values in each. All other functions in IWorkbookService work flawlessly, even with much more size of transferred data.

    What's wrong to my code?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: WCF + DataTable in OperationContract = Exception on client side

    DataTable is an in memory representation of a table. Given that, I doubt it can be serialized as WCF data.

    Why not return a type safe array of your data? In other words, create DownPayment contract class and return an array of these objects.

    Code:
     
    [ServiceContract]
    public interface IWorkbookService
    {
        [OperationContract]
        DownPayment[] GetDownpayments(KeyValuePair<int, string> sgm);
    }
     
    [DataContract]
    public class DownPayment
    {
      ...
    }

  3. #3
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: WCF + DataTable in OperationContract = Exception on client side

    DataTable can definitelly be passed trought WCF channel. Other question is, if it is the right approach (I think it isn't).

    Senglory, how large is the data you are passing? May something goes time out before it is completely serialized, maybe DB doesn't answer in time... and maybe a proxy or other security software cancels the communication, because it dislike something.

    Other methods with other types works? Also try to return empty datatable to see if it goes trought.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured