是否可以自定义WCF RIA Services端点的参数?具体来说,我想为端点创建自定义绑定,并增加maxReceivedMessageSize以允许发送大小为几兆字节的文件的内容.
[InvalidOperationException]: The
contract name MyNamespace.MyService
Could not be found in the list of
contracts implemented by the service
MyNamespace.MyService
web.config中
<system.serviceModel> <bindings> <customBinding> <binding name="CustomBinaryHttpBinding"> <binaryMessageEncoding /> <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" /> </binding> </customBinding> </bindings> <services> <service name="MyNamespace.MyService"> <endpoint address="" binding="wsHttpBinding" contract="MyNamespace.MyService" /> <endpoint address="/binary" binding="customBinding" bindingConfiguration="CustomBinaryHttpBinding" contract="MyNamespace.MyService" /> </service> </services> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel>
解决方法
我们遇到了类似的问题 – 我们希望使用WCF-RIA服务调用操作将Silverlight客户端的大位图发送到服务器.
Web.config中的以下更改为我们工作:
<httpRuntime requestValidationMode="2.0" maxRequestLength="6225920"/>
见How to configure Parameter/Message length for WCF-RIA-Service operation