自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

引用WCF服務(wù)正確實(shí)現(xiàn)方法介紹

開發(fā) 開發(fā)工具
我們今天將會(huì)通過這篇文章為大家詳細(xì)講解有關(guān)引用WCF服務(wù)的相關(guān)實(shí)現(xiàn)方法。主要包括我們介紹的兩種方式來實(shí)現(xiàn)。

當(dāng)我們?cè)趯?shí)際編程中需要對(duì)WCF服務(wù)進(jìn)行引用的時(shí)候,需要兩種方法來實(shí)現(xiàn)。那么今天我們就針對(duì)引用WCF服務(wù)的相關(guān)方法來進(jìn)行一個(gè)詳細(xì)介紹。希望這里介紹的內(nèi)容可以解決朋友在實(shí)際應(yīng)用中碰到的問題。

1.在項(xiàng)目的ServiceReferences.ClientConfig文件中加入WCF服務(wù)定義,如下:

  1. < configuration>   
  2. < system.serviceModel>   
  3. < bindings>   
  4. < basicHttpBinding>   
  5. < binding name="BasicHttpBinding_IService" 
    maxBufferSize="2147483647"   
  6. maxReceivedMessageSize="2147483647">   
  7. < security mode="None" />   
  8. < /binding>   
  9. < /basicHttpBinding>   
  10. < /bindings>   
  11. < client>   
  12. < endpoint address="http://localhost:2442/Service1.svc" 
    binding="basicHttpBinding"   
  13. bindingConfiguration="BasicHttpBinding_IService" 
    contract="ServiceReference1.IService1"   
  14. name="BasicHttpBinding_IService" />   
  15. < /client>   
  16. < /system.serviceModel>   
  17. < /configuration>   
  18. < configuration> 
  19. < system.serviceModel> 
  20. < bindings> 
  21. < basicHttpBinding> 
  22. < binding name="BasicHttpBinding_IService" 
    maxBufferSize="2147483647" 
  23. maxReceivedMessageSize="2147483647"> 
  24. < security mode="None" /> 
  25. < /binding> 
  26. < /basicHttpBinding> 
  27. < /bindings> 
  28. < client> 
  29. < endpoint address="http://localhost:2442/Service1.svc" 
    binding="basicHttpBinding" 
  30. bindingConfiguration="BasicHttpBinding_IService" 
    contract="ServiceReference1.IService1" 
  31. name="BasicHttpBinding_IService" /> 
  32. < /client> 
  33. < /system.serviceModel> 
  34. < /configuration> 

在CS文件中,使用如下代碼引用WCF服務(wù)

  1. var client = new ServiceReference1.Service1Client();   
  2. var client = new ServiceReference1.Service1Client(); 

第二種方式:在CS文件中,直接定義引用WCF服務(wù),代碼如下:

  1. Binding binding = new BasicHttpBinding();   
  2. EndpointAddress endPoint = new EndpointAddress(   
  3. "http://localhost:2442/Service1.svc");   
  4. Service1Client client = new Service1Client(binding, endPoint);   
  5. Binding binding = new BasicHttpBinding();  
  6. EndpointAddress endPoint = new EndpointAddress(  
  7. "http://localhost:2442/Service1.svc");  
  8. Service1Client client = new Service1Client(binding, endPoint);  

以上兩種方式都能引用WCF服務(wù),比如***種方式,如果沒有定義配置文件,則會(huì)報(bào) 找不到鍵值的錯(cuò)誤提示.

【編輯推薦】

  1. 兩個(gè)基本W(wǎng)CF應(yīng)用技巧總結(jié)
  2. WCF擴(kuò)展點(diǎn)在自定義運(yùn)行時(shí)使用
  3. WCF客戶端具體搭建方法解析
  4. WCF IDisposable接口應(yīng)用功能詳解
  5. WCF REST正確定義方法介紹
責(zé)任編輯:曹凱 來源: CSDN
相關(guān)推薦

2010-02-26 10:30:03

ASP.NET Aja

2010-03-01 17:44:39

Silverlight

2010-02-26 08:59:10

WCF服務(wù)宿主程序

2010-02-26 11:22:16

LitwareHR使用

2010-02-24 10:41:28

WCF服務(wù)保護(hù)

2010-03-04 11:12:02

Python AOP

2010-02-25 13:48:23

WCF動(dòng)態(tài)創(chuàng)建代碼

2010-02-25 09:13:34

WCF異步調(diào)用

2010-02-25 10:10:29

WCF使用Header

2010-02-24 10:07:48

WCF跨越邊界

2010-03-01 10:26:40

WCF異步服務(wù)

2010-02-24 13:48:44

MSMQ使用WCF

2009-12-21 10:09:26

WCF創(chuàng)建客戶端服務(wù)對(duì)

2010-03-04 15:12:33

Python算法

2010-01-14 17:52:54

VB.NET顯示系統(tǒng)信

2010-01-26 17:18:13

Android讀寫文件

2010-02-23 17:05:38

2010-02-25 16:07:28

WCF REST

2010-02-22 14:28:35

WCF實(shí)現(xiàn)loadin

2010-03-02 16:58:11

AJAX WCF服務(wù)項(xiàng)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)