-1

Web アプリケーションで WCF サービスを使用しています。2 つのサービスがあり、1 つのメソッドが最初にあり、サービスを介して呼び出している間、2 番目 which returns string に a を返します。しかし、私は次のことを得るDataTableFirst one is working properlywhile calling second oneexception ここに画像の説明を入力

ここにサーバーの設定があります

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

4

2 に答える 2

1

以下をお試しください。

1-SvcTraceViewerユーティリティを使用して、問題の原因を追跡します。2-このようにWCFから返すデータテーブルに名前を付けます。

new DataTable("someName");

WCF:DataTableが名前で初期化されていません。理由を確認してください。

于 2012-07-11T10:47:50.037 に答える
0

次のコードを使用してみました。今は正常に動作しています

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

Jani5eからこの ans を取得しました

于 2012-07-12T05:56:53.113 に答える