-1

I am using WCF service in a web application. Two services are and one method which returns string is there in first and returns a DataTable in second First one is working properly while i am calling through the service. But while calling second one i get the following exception enter image description here

Here is the config in server

  <service behaviorConfiguration="ServiceBehavior" name="RmtUsers.Menu">
    <endpoint address="" binding="wsHttpBinding" contract="IRmtUsers.IMenu">
      <identity>
        <dns value="192.168.50.35"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>

  <service behaviorConfiguration="ServiceBehavior" name="RmtUsers.Product">
    <endpoint address="" binding="wsHttpBinding" contract="IRmtUsers.IProduct">
      <identity>
        <dns value="192.168.50.35"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
          </services>
      <behaviors>             <serviceBehaviors>
          <behavior name="ServiceBehavior">
              <serviceMetadata httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="true"/>
          </behavior>             </serviceBehaviors>         </behaviors>    </system.serviceModel>

In the client

 <bindings>
  <wsHttpBinding>
    <binding name="WSHttpBinding_IMenu" closeTimeout="00:01:00" openTimeout="00:01:00"
      receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
      transactionFlow="false" hostNameComparisonMode="StrongWildcard"
      maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
      textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
        maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00"
        enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true"
          algorithmSuite="Default" />
      </security>
    </binding>
    <binding name="WSHttpBinding_IProduct" closeTimeout="00:10:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
    bypassProxyOnLocal="false" transactionFlow="falsehostNameComparisonMode="StrongWildcard"
      maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
      textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00"
        enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true"
          algorithmSuite="Default" />
      </security>
    </binding>

1
  • 2
    You're probably getting an error when WCF tries to serialize the DataTable - use a DataSet again (if you must you built-in .NET Types). The exception you'r seeing could be caused by any number of things, and in this case it's probably because the service enters a faulted state (due to the serialization error) and then times out. Commented Jul 11, 2012 at 19:48

2 Answers 2

1

Try following.

1 - Use SvcTraceViewer utility to trace the cause of the issue. 2 - Give some name to the datatable that you are returning from WCF like this.

new DataTable("someName");

WCF: DataTable was not initialized with a name. Note sure why..

Sign up to request clarification or add additional context in comments.

1 Comment

I had a similar issue and again all I needed was to name my DataTable, thanks.
0

I tried using the following code. Now its working fine

   DataTable dt = new DataTable("products");
     dt= getData();  
     DataSet ds = new DataSet();
     ds.Tables.Add(dt);
     return ds.Tables[0];

I got this ans from Jani5e

1 Comment

See my comment above - based on my experiences, the DataTable won't serialize, but a DataSet will.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.