随笔分类 -  WCF

WCF
摘要:1.记账单serviceusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ServiceModel;namespace DealerFund{ publi... 阅读全文
posted @ 2014-04-16 22:26 feidaochuanqing 阅读(189) 评论(0) 推荐(0)
摘要:serviceusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ServiceModel;using Server;public class CalculateService : ICalculate{ #region ICalculate 成员 public string GetCalculate() { return Guid.NewGuid().ToString(); } #endregion}using ... 阅读全文
posted @ 2014-03-01 15:07 feidaochuanqing 阅读(161) 评论(0) 推荐(0)
摘要:1.首先要确保已经安装消息队列msmq2.Contract&Serviceusing System;using System.Collections.Generic;using System.Linq;using System.ServiceModel;using System.Text;using System.Threading.Tasks;namespace Server{ [ServiceContract] public interface IPick { [OperationContract(IsOneWay=true)] ... 阅读全文
posted @ 2013-12-12 23:40 feidaochuanqing 阅读(208) 评论(0) 推荐(0)
摘要:namespace Client{ class CalculateClient:System.ServiceModel.ClientBase,ICalculate { public CalculateClient(Binding binding, EndpointAddress endPointAddress) : base(binding, endPointAddress) { } #region ICalculate 成员 public string Add(int a... 阅读全文
posted @ 2013-11-30 09:43 feidaochuanqing 阅读(241) 评论(0) 推荐(0)
摘要:服务端class Program { static void Main(string[] args) { Uri listenURI = new Uri("http://127.0.0.1:9988/listener"); Binding basicBinding = new BasicHttpBinding(); //通过绑定构建信道监听器工厂 IChannelListener channelListener = basicBinding.BuildChannelList... 阅读全文
posted @ 2013-11-30 08:57 feidaochuanqing 阅读(246) 评论(0) 推荐(0)
摘要:Person.svc注意这里的Service直接应用dll文件中的名称空间+类名就可以了,不用置顶dll文件所在的位置了,系统会自动根据名称去所有的dll文件中按照名称来查找。PersonService.DLLusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace PersonService{ public class PersonS:IPerson { public string GetName() { ... 阅读全文
posted @ 2013-11-21 21:38 feidaochuanqing 阅读(180) 评论(0) 推荐(0)
摘要:1.Service Layerusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Services{ public class PersonService:IPerson { Person IPerson.GetPerson(string personid) { Person p = new Person() { PersonId = perso... 阅读全文
posted @ 2013-11-17 19:06 feidaochuanqing 阅读(222) 评论(0) 推荐(0)
摘要:1.扩展OperationBehaviorusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ServiceModel.Description;using System.ServiceModel.Dispatcher;namespace Extend2{ [AttributeUsage(AttributeTargets.Method)] public class MyOperationBehavior:Attribute,IOperationBe... 阅读全文
posted @ 2013-11-11 18:11 feidaochuanqing 阅读(362) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2013-10-15 21:19 feidaochuanqing 阅读(272) 评论(0) 推荐(0)
摘要:-------------------ICustomer(接口类)------------------------------------[ServiceContract] public interface ICustomer { [OperationContract] [TransactionFlow(TransactionFlowOption.Allowed)] int RegisterCustomer(Customer customer);//注册一个客户 }------------------IRental(接口类)-----... 阅读全文
posted @ 2013-10-11 13:50 feidaochuanqing 阅读(221) 评论(0) 推荐(0)
摘要:-------------interface---------------------- /// /// 租赁合同管理 /// [ServiceContract] public interface IRental { [OperationContract] [FaultContract(typeof(RentalRegistFault))] string RegisterCarRental(RentalRegistraction rentalRegistraction);//注册一个租赁合同 [OperationContract] [FaultContract(typeof(RentalR.. 阅读全文
posted @ 2013-10-11 10:39 feidaochuanqing 阅读(272) 评论(0) 推荐(0)
摘要:----------clientProxy------------------class CarRentalPrxoxy:ClientBase,IRental { public CarRentalPrxoxy() :base("RentalServiceEndPoint") { } #region IRental 成员 public string RegisterCarRental(RentalRegistraction rentalRegistraction) { return Channel.RegisterCarRental(rentalRegistraction); 阅读全文
posted @ 2013-10-10 15:31 feidaochuanqing 阅读(526) 评论(0) 推荐(0)
摘要:-------interface-------------[ServiceContract] public interface ICarManagement { [OperationContract] int InsertNewCar(Car car);//插入一辆汽车 [OperationContract] bool RemoveCar(Car car);//移除一辆车 [OperationContract] void UpdateMilage(Car car);//更新里程 [OperationContract] List ListCars();//获得所有的车辆信息 [Operatio. 阅读全文
posted @ 2013-10-10 15:26 feidaochuanqing 阅读(175) 评论(0) 推荐(0)
摘要:--------------------------static ServiceHost CarManagementServiceHost; static ServiceHost CustomerServiceHost; static ServiceHost RentalServiceHost; static ServiceHost ExtentalServiceHost; static void Main(string[] args) { CarManagementServiceHost = new ServiceHost(type... 阅读全文
posted @ 2013-10-10 15:24 feidaochuanqing 阅读(294) 评论(0) 推荐(0)
摘要:WCF服务端和客户端如果传递的参数是复杂类型而且没有使用DataContract标签那么客户端对复杂类型的所有的公开属性都可见。服务端配置文件Host类ServiceHost host = new ServiceHost(typeof(CarRentalService));host.Opened += new EventHandler(host_Opened);host.Open();Console.Read();版本控制:对外的服务发布了一版之后然后对服务进行升级,就是版本控制问题:wcf什么情况下用不同的序列化的方式DataContract?XmlSerilize 阅读全文
posted @ 2013-10-10 15:21 feidaochuanqing 阅读(144) 评论(0) 推荐(0)
摘要:1.Contractnamespace BankContract{ [ServiceContract] public interface IBank { [OperationContract] [TransactionFlow(TransactionFlowOption.Mandatory)]//设置事务流,必须启用使用 void IntoMoney(int money); [OperationContract] [TransactionFlow(TransactionFlowOption.Mandatory)] void OutMoney(int money); }}2.Servicenam 阅读全文
posted @ 2013-04-06 22:42 feidaochuanqing 阅读(187) 评论(0) 推荐(0)