我可以使用 mexTcpBinding 和名字对象字符串成功调用 WCF 服务 下面是用于构建名字对象字符串的 vb 脚本
Dim addrToWCFService As String
addrToWCFService = "service4:mexAddress=net.tcp://10.44.19.20/PruCapWebCMHost/API/Excel/ExcelAPIService.svc/mexTCP, "
addrToWCFService = addrToWCFService + "address=net.tcp://10.44.19.20/PruCapWebCMHost/API/Excel/ExcelAPIService.svc, "
addrToWCFService = addrToWCFService + "contract=IExcelAPIService, contractNamespace=http://Excel/Services, "
addrToWCFService = addrToWCFService + "binding=NetTcpBinding_IExcelAPIService, bindingConfiguration=IExcelAPIService, bindingNamespace=http://Excel/Services"
web.config 中的服务配置是
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IPublicService" maxReceivedMessageSize="8388608" maxBufferSize="8388608" portSharingEnabled="true">
<security></security>
</binding>
</netTcpBinding>
</bindings><services>
<service name="ExcelAPI.ExcelAPIService" behaviorConfiguration="PublicServiceTypeBehaviors">
<endpoint address="" bindingNamespace="http://Excel/Services" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IPublicService" contract="ExcelAPI.IExcelAPIService" name="NetTcpBinding_IExcelAPIService" />
<endpoint address="mexTCP" bindingNamespace="http://Excel/Services" binding="mexTcpBinding" contract="IMetadataExchange" bindingName="NetTcpBinding_IPublicService" name="MexTcpBinding_IExcelAPIService"/>
</service>
当我调用服务中返回超过 65356 大小的数据的方法之一时,我收到错误消息,提示“已超出传入消息的最大消息大小配额 (65534)。要增加配额,请使用适当的 MaxReceivedMessageSize 属性绑定元素"
现在我正在努力将这个属性设置为更高的值。我尝试创建 Excel.exe.config 文件并放入 Excel.exe 文件夹。我现在想在我的情况下如何将 MaxReceivedMessageSize 设置为值“8388608”,以及需要设置哪个配置文件 Excel.exe.config 或其他可以告诉名字对象代理使用的东西。谁能帮我解决这个棘手的问题。
我已经创建了 Excel.exe.config 文件,并在其中添加了以下内容,但是它没有采用这些设置,任何人都可以帮我解决这个问题。或确认这是名字代理的固有问题或限制?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="IExcelAPIService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="8388608" maxBufferSize="8388608" maxConnections="10"
maxReceivedMessageSize="8388608">
<security >
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://10.44.19.20/PruCapWebCMHost/API/Excel/ExcelAPIService.svc"
binding="netTcpBinding" bindingConfiguration="IExcelAPIService"
contract="IExcelAPIService" name="NetTcpBinding_IExcelAPIService">
</endpoint>
</client>
</system.serviceModel>
</configuration>