[英]WCF - IsOneway is not behaving like it is Oneway operation
我已经在我的服务的一些方法上定义了 OneWay 属性,但它们的行为不像 Oneway 调用。 我的客户等待调用完成并从服务返回。 我假设 Oneway 操作是非阻塞操作,客户端不关心被调用的 function 会发生什么。 它只是调用并忘记它。 这是对的吗?
问题:调用 OperationContract2 后,我立即关闭代理,但我的客户端等待执行完成。
if (((ICommunicationObject)myServices).State == CommunicationState.Opened)
{
((ICommunicationObject)myServices).Close();
}
配置有问题吗?
服务器配置:
<netTcpBinding>
<binding name="GoCustomBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="0" maxReceivedMessageSize="2147483647">
</binding>
</netTcpBinding>
服务合同:
[ServiceContract]
public interface IMyServices
{
[OperationContract(IsOneWay = true, Action = "*")]
void OPeration1(List<int> someIds);
[OperationContract(IsOneWay = true)]
void OPeration2(SomeClass p1);
}
客户端代理:
[ServiceContract]
public interface IMyServices
{
[OperationContract(IsOneWay = true, Action = "*")]
void Operation1(List<int> someIds);
[OperationContract(IsOneWay = true)]
void Operation2(SomeClass p1);
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class ServiceClient : ClientBase<IMyServices>, IMyServices
{
public void ScheduleOptimization(List<int> someIds)
{
Channel.Operation1(routeID);
}
public void Operation1(SomeClass p1)
{
Channel.Operation2(pasDataMsg);
}
}
从该属性的文档中:
指定一个操作是单向操作仅意味着没有响应消息。 如果无法建立连接,或者出站消息非常大,或者服务无法足够快地读取入站信息,则可能会阻塞。 如果客户端需要非阻塞调用,则生成 AsyncPattern 操作。 有关更多信息,请参阅单向服务和使用客户端使用服务。
这些可能是你的问题吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.