我搜索並嘗試了所有以前發佈的建議解決方案,並沒有任何運氣。我顯然做錯了,我只是無法弄清楚,我希望有人能夠幫助我here.My問題是這樣的:我有一個WCF服務和一個WCF客戶端。當我調用服務並嘗試傳遞一個字節數組(將圖像上傳到服務)時,我得到一個非常模糊的Target Invokation異常錯誤。所以,我迷上了跟蹤並且跟蹤日誌告訴我消息配額大小超過了限制,但我已經修改了兩端的配置(app.config & web.config)以包含一個非常大的限制。問題是,它告訴我超過了65536的限制,但正如你從我的配置下面可以看到的那樣大於這個數量,所以就好像我的客戶端正在使用一些其他配置值,或者我沒有配置它是正確的,它忽視了我擁有的東西。有人能幫我嗎?如何將圖像數據發送到WCF服務
App.Config中:
的Web.Config:
你們可以提供任何幫助將不勝感激。我一直在這個問題上停留兩天。
謝謝大家。
這裏的實際配置代碼:
<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);
你嘗試更改配置文件後,重新啓動服務器?另外,你有沒有嘗試發送小於65K的圖像?那將是一個開始的好地方。 –
提示:使用正確的格式('{}'按鈕)將文本代碼(也就是XML)作爲文本進行發佈。使搜索等更容易。 –
@Paul Sasik我確實嘗試發送小於65k的小圖片,並且確實有效。問題是,我將要發送大約90 - 120K的圖像大小。 –