Click here to Skip to main content
15,905,000 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
EndpointAddress _endpoint = new EndpointAddress("net.tcp://" + szWord_Operation_Ip + "/CalcService");
var channel = new ChannelFactory<Process_Word_Document.ICalcService>(_binding, _endpoint);
  var _client = channel.CreateChannel();
 _client.Update_Document_Properties(szFilePath);



OR


C#
EndpointAddress _endpoint = new EndpointAddress("net.tcp://" + szWord_Operation_Ip + "/CalcService");
using (Process_Word_Document.CalcServiceClient _client = new Process_Word_Document.CalcServiceClient(_binding, _endpoint))
                _client.Update_Document_Properties(szFilePath);



I just want to know the Difference between these calling method
which one should I prefer

What I have tried:

checked https://stackoverflow.com/questions/21884177/best-practice-to-call-wcf-service
Posted
Updated 28-May-18 7:23am
v3

1 solution

Second way you mentioned is the prefered way to call a WCF service. You need to create a client first and call the method from the client,


EndpointAddress _endpoint = new EndpointAddress("net.tcp://" + szWord_Operation_Ip + "/CalcService");
using (Process_Word_Document.CalcServiceClient _client = new Process_Word_Document.CalcServiceClient(_binding, _endpoint))
_client.Update_Document_Properties(szFilePath)
 
Share this answer
 
Comments
kedar001 29-May-18 3:57am    
But what are the disadvantage of 1st one
In some cases iam getting timeout error for 1st one so I have used second method and that solved the timeout error ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900