WCF - 如何将 serviceBehaviors 附加到 WCF 端点(无标记)
我正在使用第三方 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将
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.看起来您显示的配置是您的客户端配置。这仅表明您将如何与服务进行通信。它不会向服务提供有关您客户的任何信息。
请记住,服务不了解客户端,客户端对服务的唯一了解是通过元数据交换。
除非服务提供某种方法来执行此操作(不通过任何 .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.