WCF 配置超时“每个操作"

问题描述:

我有一个服务,其中 1 个操作可能需要很多时间,而其他操作应该很快结束,我可以使用 OperationBehavior(或其他东西)配置超时(发送\接收)不同(在操作级别)) ?

I have a service in which 1 operation can take a lot of time and the others should end very quickly, can I configure using an OperationBehavior (or something else) the timeout (send\receive) to be different (at operation level) ?

不能,超时只能在绑定配置中指定,并且绑定配置附加到端点 - 因此该端点上的所有服务方法都获得相同的超时时间.

No, the timeouts can only be specified in a binding configuration, and a binding configuration is attached to an endpoint - so all the service methods on that endpoint get the same timeouts.

您唯一能做的就是将您的服务拆分为两个合同,并在两个单独的端点(FastEndpoint"与SlowEndpoint")上公开两个,然后为每个端点使用不同的设置来处理这种情况.

The only thing you could do is split up your service into two contracts and expose two on two separate endpoints ("FastEndpoint" vs. "SlowEndpoint") and then use different settings for each endpoint to handle this situation.