这是调用WCF服务的正确方法 [英] Which is the correct way to call WCF service
本文介绍了这是调用WCF服务的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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
OR
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);
我只是想知道这些之间的区别调用方法
我应该选择哪一个
我尝试过:
已检查https://stackoverflow.com/questions/21884177/best-practice-to-call-wcf-service
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
推荐答案
您提到的第二种方式是调用WCF服务的首选方式。您需要先创建一个客户端并从客户端调用该方法,
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)
这篇关于这是调用WCF服务的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文