2012-07-11 46 views
-1

我在Web应用程序中使用WCF服务。有两种服务,一种是which returns string,第一种是返回DataTable,第二种是 First one is working properly,而我通过该服务拨打电话。 但while calling second one我得到以下exception enter image description hereWCF CommunicationException

这里是服务器的配置

<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> 

在客户端

<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> 

+0

检查内部异常 – VJAI 2012-07-11 17:29:03

+2

你可能会得到一个错误,当WCF尝试序列数据表 - 再次使用DataSet(如果你必须建在.NET类型中)。您看到的异常可能是由许多因素造成的,在这种情况下,可能是因为服务进入故障状态(由于序列化错误),然后超时。 – Tim 2012-07-11 19:48:02

回答

1

请尝试以下操作。

1 - 使用SvcTraceViewer实用程序来追踪问题的原因。 2 - 给你从WCF返回的数据表做一些这样的名字。

new DataTable("someName"); 

WCF:DataTable未用名称初始化。请注意为什么..

+0

我试过,但不workng ..可以ü请检查我的回答 – Nithesh 2012-07-12 05:59:15

+0

我有一个类似的问题,我需要的一切是命名我的'DataTable',谢谢。 – 2017-01-16 22:44:36

0

我试着用下面的代码。现在,它的做工精细

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

我得到了这个答案从Jani5e

+0

看到我上面的评论 - 根据我的经验,DataTable不会序列化,但DataSet会。 – Tim 2012-07-12 18:09:19

相关问题