我正在使用名字符串從excel VBA代碼中調用我的WCF服務。然而,如我的服務返回大的數據作爲響應,EXCEL給出錯誤消息從excel調用WCF服務給出了接收到的郵件大小的錯誤
「最大消息大小配額用於傳入消息(65534)已被超過。爲了增加配額使用的MaxReceivedMessageSize屬性的適當的結合元件上」
這裏是別名字符串:
addrToService = "service4:mexAddress=""net.tcp://localhost/MyApp/API/Excel/ExcelAPIService.svc/mexTCP"", "
addrToService = addrToService + "address=""net.tcp://localhost/PruCapWebCMHost/API/Excel/ExcelAPIService.svc"", "
addrToService = addrToService + "contract=""IExcelAPIService"", contractNamespace=""http://Prucap/Services"", "
addrToService = addrToService + "binding=""NetTcpBinding_IExcelAPIService"", bindingNamespace=""http://MyApp/Services"""
要解決這個問題,我增加了我的WCF服務的web.config文件的大小,如下圖所示:
<netTcpBinding>
<binding name="NetTcpBinding_IPublicService" maxBufferPoolSize="8388608" maxBufferSize="8388608" maxReceivedMessageSize="8388608" portSharingEnabled="true">
</binding>
</netTcpBinding>
<basicHttpBinding>
<binding name="BasicHttpBidning_IPublicService" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:05:00" receiveTimeout="00:05:00" maxReceivedMessageSize="8388608" />
<binding name="BasicHttpBidning_ISecureService" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:05:00" receiveTimeout="00:05:00" maxReceivedMessageSize="8388608" />
</basicHttpBinding>
....
<service name="ExcelAPIService" behaviorConfiguration="PublicServiceTypeBehaviors">
<endpoint address="" bindingNamespace="http://MyApp/Services" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IPublicService" contract="API.Service.ExcelAPI.IExcelAPIService" name="NetTcpBinding_IExcelAPIService" />
<endpoint address="" bindingNamespace="http://MyApp/Services" binding="basicHttpBinding" bindingConfiguration="BasicHttpBidning_IPublicService" contract="API.Service.ExcelAPI.IExcelAPIService" name="BasicHttpBidning_IExcelAPIService" />
<endpoint address="mex" bindingNamespace="http://MyApp/Services" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="mexTCP" bindingNamespace="http://MyApp/Services" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
</service>
根據關於此主題的各種論壇,上述解決方案應該可行。但從Excel中調用時,這在我的情況下不起作用。有什麼我需要做從Excel側設置maxReceivedMessageSize?如果是的話,我該如何使用VBA代碼來做到這一點?
其他信息:
我使用Office 2010(使用VBA),Windows 7的教授,64位操作系統
您使用moniker字符串而不僅僅是通常的ChannelFactory機制的具體原因是什麼? – 3dd
節省額外的編碼工作 –
請謹慎解釋,因爲您好像試圖解決這個問題,浪費編碼工作。如果你在客戶端使用ChannelFactory,你可以使用配置文件,並設置最大尺寸 – 3dd