創(chuàng)新互聯(lián)建站服務(wù)項(xiàng)目包括泗洪網(wǎng)站建設(shè)、泗洪網(wǎng)站制作、泗洪網(wǎng)頁制作以及泗洪網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,泗洪網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到泗洪省份的部分城市,未來相信會繼續(xù)擴(kuò)大服務(wù)區(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
{
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 GetList()
{
return base.Channel.GetList();
}
}
}
創(chuàng)建類BookServiceProxy
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 list = new List();
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 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;
}
}
}
}
網(wǎng)站欄目:WCF客戶端代理-創(chuàng)新互聯(lián)
路徑分享:
http://weahome.cn/article/dcepoe.html