自定义 WCF RIA 服务端点

发布于 2024-09-05 12:11:46 字数 1131 浏览 2 评论 0原文

是否可以自定义 WCF RIA 服务端点的参数?具体来说,我想为端点创建自定义绑定并增加 maxReceivedMessageSize ,以允许发送几兆字节大小的文件内容。

我尝试过干预 web.config,但出现以下错误:

[InvalidOperationException]: 合约名称 MyNamespace.MyService 在列表中找不到 服务执行的合同 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>

Is it possible to customize the parameters of a WCF RIA Services endpoint? Specifically, I would like to create a custom binding for the endpoint and increase the maxReceivedMessageSize to allow sending the contents of a file that is a few megabytes in size.

I've tried meddling in the web.config, but I'm getting the following error:

[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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月野兔 2024-09-12 12:11:46

我们遇到了类似的问题 - 我们希望使用 WCF-RIA 服务调用操作将大型位图从 Silverlight 客户端发送到服务器。

Web.config 中的以下更改对我们有用:

<httpRuntime requestValidationMode="2.0" maxRequestLength="6225920"/>

请参阅 如何为 WCF-RIA-Service 操作配置参数/消息长度

We had a similar problem - we want to send large bitmaps fom Silverlight client to Server using WCF-RIA service invoke operation.

The following change in Web.config worked for us:

<httpRuntime requestValidationMode="2.0" maxRequestLength="6225920"/>

See How to configure Parameter/Message length for WCF-RIA-Service operation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文