Reputation: 499
I am trying to create one way communication with WCF service (NetTcpBinding), but it does not seems to be working.
Interface:
[ServiceKnownType(typeof(ProcessParameter))]
[ServiceKnownType(typeof(string))]
[ServiceContract]
public interface IExecServiceHost
{
[OperationContract(IsOneWay = true)]
void ExecBPWithPP(ISysObject _caller, UserEntity _currentUser, string _bpName, IProcessParameter _parameter, string _afterBP);
[OperationContract(IsOneWay = true)]
void ExecBPWithNVC(ISysObject _caller, UserEntity _currentUser, string _bpName, Dictionary<string, string> _parameter, string _afterBP);
}
Service:
Uri[] serviceURL = new Uri[] { new Uri(ExecBPEndPointURL) };
ServiceHost host;
host = new ServiceHost(typeof(ExecServiceHost), serviceURL);
host.AddServiceEndpoint(typeof(IExecServiceHost), new NetTcpBinding(), "ExecBP");
host.Open();
Console.ReadKey();
host.Close();
Client:
using(ChannelFactory<IExecServiceHost> httpFactory = new ChannelFactory<IExecServiceHost>(
new NetTcpBinding(),
new EndpointAddress(ExecBPEndPointURL)))
{
IExecServiceHost httpProxy = httpFactory.CreateChannel();
Dictionary<string, string> serviceBPParam = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
foreach(string key in _parameter.Keys)
serviceBPParam.Add(key, _parameter[key]);
httpProxy.ExecBPWithNVC(_caller, _currentUser, _bpName, serviceBPParam, _afterBP);
httpFactory.Close();
}
When I am calling WCF client from ASP.net page it wait till process completion. Please help me what I am missing. Also, so far I am not using any config for service/end point.
In one way communication wcf client is not supposed to wait for wcf server to complete the execution. This is the main issue.
Upvotes: 0
Views: 267
Reputation: 31760
You are confusing one way calls with async calls.
With Async, the client makes the call but then control returns immediately and any response is handled via callback. The thread will not wait for the response. This is the behavior you are expecting to see I think.
With one-way, the service will not return a response other than the http 200, and this is regardless of any internal state changes as a result of executing the call handling code. However, the client will still block until it receives the 200, which under load could still take a long time.
Additionally, if the connection fails the client channel will still fault, so even though it's one-way, you will still need to handle these kinds of failures on the client.
See here for more:
It is important to realize that while some one-way applications return as soon as the outbound data is written to the network connection, in several scenarios the implementation of a binding or of a service can cause a WCF client to block using one-way operations. In WCF client applications, the WCF client object does not return until the outbound data has been written to the network connection. This is true for all message exchange patterns, including one-way operations; this means that any problem writing the data to the transport prevents the client from returning. Depending upon the problem, the result could be an exception or a delay in sending messages to the service.
Upvotes: 1