日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯網營銷解決方案
引用WCF服務正確實現方法介紹

當我們在實際編程中需要對WCF服務進行引用的時候,需要兩種方法來實現。那么今天我們就針對引用WCF服務的相關方法來進行一個詳細介紹。希望這里介紹的內容可以解決朋友在實際應用中碰到的問題。

創(chuàng)新互聯是一家專業(yè)提供孟村企業(yè)網站建設,專注與成都做網站、成都網站設計、HTML5、小程序制作等業(yè)務。10年已為孟村眾多企業(yè)、政府機構等服務。創(chuàng)新互聯專業(yè)網絡公司優(yōu)惠進行中。

1.在項目的ServiceReferences.ClientConfig文件中加入WCF服務定義,如下:

 
 
 
  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服務

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

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

 
 
 
  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服務,比如***種方式,如果沒有定義配置文件,則會報 找不到鍵值的錯誤提示.

【編輯推薦】

  1. 兩個基本WCF應用技巧總結
  2. WCF擴展點在自定義運行時使用
  3. WCF客戶端具體搭建方法解析
  4. WCF IDisposable接口應用功能詳解
  5. WCF REST正確定義方法介紹

當前標題:引用WCF服務正確實現方法介紹
文章起源:http://www.5511xx.com/article/dpoigeh.html