欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

WCF客戶端代理-創(chuàng)新互聯(lián)

    創(chuàng)新互聯(lián)建站服務項目包括泗洪網(wǎng)站建設、泗洪網(wǎng)站制作、泗洪網(wǎng)頁制作以及泗洪網(wǎng)絡營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關系等,向廣大中小型企業(yè)、政府機構等提供互聯(lián)網(wǎng)行業(yè)的解決方案,泗洪網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務的客戶以成都為中心已經(jīng)輻射到泗洪省份的部分城市,未來相信會繼續(xù)擴大服務區(qū)域并繼續(xù)獲得客戶的支持與信任!
  • 創(chuàng)建類庫WCFServiceProxy
  • 添加System.ServiceModel、WCFService(見上篇文章)引用
  • 創(chuàng)建類:BookServiceClient
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Text;
using System.Threading.Tasks;
using WCFService;
using WCFService.Models;

namespace WCFServiceProxy
{
public class BookServiceClient : ClientBase<IBookService>, IBookService
    {
public BookServiceClient() : base() { }
public BookServiceClient(string endpointConfigurationName) : base(endpointConfigurationName) { }
public BookServiceClient(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress) { }
public BookServiceClient(string endpointConfigurationName, EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress) { }
public BookServiceClient(Binding binding, EndpointAddress remoteAddress) : base(binding, remoteAddress) { }
public bool Add(string name, double price)
        {
return base.Channel.Add(name, price);
        }

public List<Book> GetList()
        {
return base.Channel.GetList();
        }
    }
}
創(chuàng)建類BookServiceProxyWCF客戶端代理
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using WCFService.Models;

namespace WCFServiceProxy
{
public static class BookServiceProxy
    {
private static string _clientEndpointName = "bookInfo";
static List<Book> list = new List<Book>();
public static bool Add(string name, double price)
        {
            BookServiceClient client= null;
try
            {
                client= new BookServiceClient(_clientEndpointName);
                client.Add(name, price);
                client.Close();
return true;
            }
catch (Exception ex)
            {
if (client != null && client.State != CommunicationState.Closed)
                {
                    client.Abort();
                    client= null;
                }
return false;
            }
finally
            {
                client= null;
            }
        }

public static List<Book> GetList()
        {
            BookServiceClient client= null;
try
            {
                client= new BookServiceClient(_clientEndpointName);
                list= client.GetList();
                client.Close();
return list;
            }
catch (Exception ex)
            {
if (client != null && client.State != CommunicationState.Closed)
                {
                    client.Abort();
                    client= null;
                }
return null;
            }
finally
            {
                client= null;
            }
        }
    }
}

文章標題:WCF客戶端代理-創(chuàng)新互聯(lián)
轉載源于:http://www.chinadenli.net/article4/dcepoe.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版網(wǎng)站設計公司軟件開發(fā)標簽優(yōu)化Google品牌網(wǎng)站設計

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)