I have this problem. I have two WCF services - ServiceA
and ServiceB
. Both services are host in different windows services and communicate via net.tcp. Client access Service A
. In Service A
I access Service B
. Problem what I got is that I want to communication be duplex.
That is I want client to call method TestA
in ServiceA
. This method would call method TestB
in ServiceB
. Method TestB
would make some long duration action and then raises callback back to ServiceA
that would raises callback to client. Methods TestA
and TestB
are one way contracts.
I can get to the point in which ServiceA
raises callback back to client. Then it crashes on InvalidCastException trying to get callback channel in operation context.
IServiceACallback Callback
{
get
{
return OperationContext.Current.GetCallbackChannel<IServiceACallback>();
}
}
Is it because I am in a different thread and operation context is just simply not complete? Because I can raise callback back to client when I am not doing it from another callback from ServiceB
. Can I solve it with some service attributes maybe? Or is there some communication pattern that I can use?