2012-03-28 6 views
0

比較的大きなオブジェクトグラフが返されたときに、SharePointサイトからWCFサービスを呼び出し、以下の詳細でクライアントでエラーが発生します。大きなオブジェクトグラフを処理するときにクライアント側の漠然としたWCFエラー

サービスをデバッグすると、オブジェクトが正しく構築され、メソッドは(他のオブジェクトのリストを持つ)最終オブジェクトを正しく返します。しかし、私はサービスメソッド呼び出しでクライアント側で例外を取得します。

ほとんどの場合、Thieサービス/方法は正常に機能します。以下は、(悪いフォーマット用の謝罪)

サービスコンフィグサービス構成されている:サービスインスタンスを作成するための

<system.serviceModel> 
<services> 
<service behaviorConfiguration="StandardServiceBehaviour" name="Thd.K2.Web.DataServicesLibrary.Common.Services.AdminService"> 

      <endpoint address="soap" binding="basicHttpBinding" name="AdminService" contract="Thd.K2.Web.DataServicesLibrary.Common.Interfaces.IAdminService" /> 
      <endpoint address="mex" binding="mexHttpBinding" name="Metadata" contract="IMetadataExchange" kind="mexEndpoint" endpointConfiguration="" /> 
     </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
      <behavior name="StandardServiceBehaviour"> 
        <serviceMetadata httpsGetEnabled="false" /> 
        <serviceDebug includeExceptionDetailInFaults="true" /> 
      </behavior>     
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="customBinding" hostNameComparisonMode="StrongWildcard" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00" maxReceivedMessageSize="1000000" maxBufferSize="1000000" maxBufferPoolSize="1000000" transferMode="Buffered" messageEncoding="Text" textEncoding="utf-8" bypassProxyOnLocal="false" useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="2147483647" maxStringContentLength="214748364" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
       <security mode="Transport" /> 
      </binding> 
     </basicHttpBinding> 
     <webHttpBinding> 
      <binding name="webBinding" bypassProxyOnLocal="true" useDefaultWebProxy="false" hostNameComparisonMode="WeakWildcard" sendTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:05:00" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"> 
      <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" /> 
      <security mode="Transport"> 
      </security> 
      </binding> 
     </webHttpBinding> 
    </bindings> 
</system.serviceModel> 

クライアントの方法は

public static TServiceType GetServiceClient<TServiceType>(ConnStringsType connectionStringType, Page callingPage) 
     where TServiceType : class 
    { 
     var spUrl = GetConnectionString(connectionStringType, callingPage); 

    var result = new BasicHttpBinding(BasicHttpSecurityMode.None);    
     if(spUrl.ToLower().StartsWith("https")) 
     { 
      result = new BasicHttpBinding(BasicHttpSecurityMode.Transport); 
     }    
     result.MaxReceivedMessageSize = int.MaxValue - 1; 
     result.MaxBufferSize = int.MaxValue-1; 
     if (!string.IsNullOrEmpty(spUrl)) 
     { 
      return (TServiceType)Activator.CreateInstance(typeof(TServiceType), result, new EndpointAddress(spUrl)); 
     } 
     return null; 
    } 

エラー:

エラーoccu HTTP応答をhttp://localhost:90/AdminService.svc/soapに受信している間は応答しません。これは、サービスエンドポイントがHTTPプロトコルを使用しないでバインドすることが原因である可能性があります。これは、(おそらくサービスのシャットダウンのために)サーバーによって中止されたHTTP要求コンテキストが原因である可能性もあります。詳細はサーバーログを参照してください。 スタック:

サーバースタックトレース:System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebExceptionで (WebException webException、HttpWebRequestの要求、HttpAbortReason abortReason) System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpanのタイムアウトで) at System.ServiceModel.Channels.RequestChannel.Request(メッセージメッセージ、TimeSpanタイムアウト) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(メッセージメッセージ、TimeSpanタイムアウト) at System.ServiceModel.Channels.ServiceChannel.Call(Stringアクション、Boolean oneway、ProxyOperationRuntime操作、Object [] ins、Object [] outs、TimeSpanタイムアウト)で再スローSystem.ServiceModel.Channels.ServiceChannelProxy.InvokeでSystem.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCallで、ProxyOperationRuntime動作) (IMessageがメッセージ)

例外で[0]:System.Runtimeで 。 AdminServiceClientでRemoting.Proxies.RealProxy.HandleReturnMessage IAdminService.GetBlackoutPeriodsByDescription(文字列のlang、文字列の記述)でSystem.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(のMessageData & msgData、のInt32型)で(IMessageがreqMsg、IMessageがretMsg) .GetBlackoutPeriodsByDescription(String lang、String description) at EditBlackoutDates.LoadBlackout(String descriptio n)

+0

メッセージが示しているエラーのようなサーバーのログを確認しましたか?彼らは何を言いますか? – Randolpho

+0

サービス側でエラー/例外を認識できませんでした。 – Vashu

答えて

0

@paramosh - ありがとうございました!

これはそのトリックでした。他の参考資料として、私は実際に非RESTful WCFサービスを使用していました。

private void ExpandObjectGraphItems(AdminServiceClient svc) 
    { 
     var operations = svc.Endpoint.Contract.Operations; 
     foreach (var operation in operations) 
     { 
      var dataContractBehavior = operation.Behaviors.Find<System.ServiceModel.Description.DataContractSerializerOperationBehavior>(); 
      if (dataContractBehavior != null) 
      { 
       dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue; 
      } 
     } 
    } 

追加サービスの設定に属性を以下:そこで私は、ウェブSVCメソッド呼び出しの前に機能の下に呼び出し 以下のように解決策を修正

<behavior name="StandardServiceBehaviour"> 
       <dataContractSerializer maxItemsInObjectGraph="2147483646"/>