2012-07-11 47 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

相關問題