2011-11-07 14 views
0

私は過去に投稿された提案されたソリューションをすべて検索して試しましたが、運がなかった。私は明らかに分からない何かをしていることは明らかです。誰かが私を助けてくれることを願っています。私の問題はこれです:イメージデータをWCFサービスにどのように送信しますか

私はWCFサービスとWCFクライアントを持っています。私がサービスを呼び出して、バイト配列を渡そうとすると(サービスに画像をアップロードする)、私はTarget Invokation例外エラーが発生します。これは非常に曖昧です。だから、私はトレースを繋いで、トレースログはメッセージクォータのサイズが限界を超えていると伝えていますが、実際に大きな制限を含むように両端の設定(app.config & web.config)を変更しました。問題は、それは65536の限界を超えていることを私に伝えていますが、下の設定から見ると、その量よりも大きいので、クライアントが他の設定値を使用しているかのように、それは正しく、私が持っているものを無視している。誰か助けてくれますか?

のapp.config: enter image description here

のWeb.Config: enter image description here

君たちが提供できるすべてのヘルプをいただければ幸いです。私は今この問題に2日間執着しています。

ありがとうございました。

ここでは、実際の構成コードがあります:

<system.serviceModel> 
    <bindings>    
     <wsHttpBinding> 
      <binding name="WSHttpBinding_IDataSyncService" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
       messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
       allowCookies="false"> 
       <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
       <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> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/DataSyncWCF/DataSyncService.svc" 
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDataSyncService" 
      contract="IDataSyncService" name="WSHttpBinding_IDataSyncService"> 
      <identity> 
       <dns value="localhost" /> 
      </identity> 
     </endpoint> 
    </client> 
</system.serviceModel> 

のWeb.Config:

<services> 
    <service behaviorConfiguration="DataSyncWCF.Service1Behavior" 
    name="DataSyncWCF.DataSyncService"> 
    <endpoint address="" binding="wsHttpBinding" bindingName="WSHttpBinding_IDataSyncService" 
     contract="DataSyncWCF.IDataSyncService"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 
</services> 
<bindings>  
    <wsHttpBinding> 
    <binding name="DataSyncWCF.Service1Binding" maxBufferPoolSize="2147483647" 
     maxReceivedMessageSize="2147483647" allowCookies="true"> 
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
     maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
     <security mode="None">    
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="DataSyncWCF.Service1Behavior">   
     <serviceMetadata httpGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

ここでWCFサービスを呼び出す私のコードです:WCFで

VehicleImage vi = new VehicleImage(); 
System.IO.FileStream fs = new System.IO.FileStream(@"C:\images\1FAHP35N18W1589_01.jpg",  System.IO.FileMode.Open, System.IO.FileAccess.Read); 
int len = (int)fs.Length; 
vi = new VehicleImage(); 
vi.Image = new Byte[len];    
fs.Read(vi.Image, 0, len); 

// Here's the call to the WCF Service. It never makes it to the Service because of the message size limit error. 
ResponseContract rc = client.SyncImage(vi); 
+2

あなたが設定ファイルを変更した後、サーバーを再起動してみてくださいましたか?また、65K未満の画像を送信しようとしましたか?それは始めるのに良い場所になるでしょう。 –

+0

ヒント:コード、XMLも適切な書式設定( '{} ')ボタン付きのテキストとして投稿してください。検索などをもっと簡単にします。 –

+0

@ Paul Sasik私は、65k未満の小さな画像を送信しようとしましたが、それは動作します。問題は、私はそれぞれ約90〜120Kの画像サイズを送信するつもりです。 –

答えて

4

すべてが重く(限定されています抑えられている)、理由がある。

私はあなたの設定で多くの2G番号を参照してください、それは一般的には良い考えではありません。そしてあなたはいくつか見逃しているかもしれませんが、私はSerializationLimit(略称)をすばやく見つけられません。

WCFで大きなメッセージを処理する基本的な方法は、MTOMとストリーミングの2つです。あなたのweb.config wsHttpBindingで

+0

はい、私は受け取っているエラーのために値を上げるだけです。私はそれが問題を解決するかどうかを確認するためにそのような高い値に数を増やし、私が解決策を持っていることを知った後、それを減らすために私の道を後ろ向きに進めるだろう。私はすでにMTOMを試していますが、結果も変わっていません。 –

+0

私はストリームを考えます。作業が簡単で、必要なストリーミング(非同期)動作が面白くなります。 –

1

は、設定maxReceivedMessageSize

<binding name="www" maxReceivedMessageSize="2147483647"> 
+0

はい、私はクライアントの設定とweb.configの両方でその値を設定しました。 –

+2

受信している正確なエラーメッセージを追加できますか?これは、変更が必要な設定を特定するのに役立ちます(fyi:WCFを超える非常に大きな(1GB以上の)ファイルを正常に転送しているため、固有の問題はありません)。 –