WCF - 如何将 serviceBehaviors 附加到 WCF 端点(无标记)

发布于 2024-12-19 06:04:49 字数 961 浏览 2 评论 0原文

我正在使用第三方 WCF 服务,其配置如下(其中的一部分)。我想将 serviceBehaviors 分配给端点,但这里没有 标记。在这种情况下,如何分配“serviceBehaviors”?

<client>
  <endpoint address="https://something/someservice.asmx" binding="customBinding" bindingConfiguration="ABCBinding" contract="Democlient.Soap" name="Soap" behaviorConfiguration="SoapEndpointB" />
</client>
<behaviors>
  <endpointBehaviors>
    <behavior name="SoapEndpointB">
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="SoapServiceB">
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

I am consuming a third party WCF service and its config is below (a portion of it). I wanted to assign serviceBehaviors to endpoint, but there is no <service> tag here. In this case, how do you assign 'serviceBehaviors'?

<client>
  <endpoint address="https://something/someservice.asmx" binding="customBinding" bindingConfiguration="ABCBinding" contract="Democlient.Soap" name="Soap" behaviorConfiguration="SoapEndpointB" />
</client>
<behaviors>
  <endpointBehaviors>
    <behavior name="SoapEndpointB">
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="SoapServiceB">
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

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

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

发布评论

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

评论(2

┊风居住的梦幻卍 2024-12-26 06:04:49

您将 serviceBehaviors 分配给 WCF 服务器端点,而不是客户端端点。如果您需要更改,您必须请求第 3 方 WCF 服务主机添加您寻求的服务行为。

You assign serviceBehaviors to WCF server endpoints, not to client endpoints. You would have to request the 3rd party WCF service host add the service behaviors you seek if you need them changed.

紫瑟鸿黎 2024-12-26 06:04:49

看起来您显示的配置是您的客户端配置。这仅表明您将如何与服务进行通信。它不会向服务提供有关您客户的任何信息。

请记住,服务不了解客户端,客户端对服务的唯一了解是通过元数据交换。

除非服务提供某种方法来执行此操作(不通过任何 .Net 或 WCF 机制),否则您的客户端无法也不应该指定服务应如何运行。给定的服务可能正在处理来自许多不同客户端的请求,每个客户端都有自己的需求。没有什么好的办法来处理这种情况。

It looks like the configuration you're showing is your client side configuration. That just indicates how you're going to be communicating with the service. It doesn't tell the service anything about your client.

Remember that the service has no knowledge of the client, and the only knowledge that the client has of the service is via metadata exchange.

Unless the service offers some method for doing so (not via any .Net or WCF mechanism), your client can not specify how the service should behave, nor should it. A given service may be handling requests from many different clients, each with their own desires. There's just no good way to handle that kind of situation.

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