contracts

Only an absolute URI can be used as a base address

送分小仙女□ 提交于 2020-01-14 09:40:36
问题 Please help getting exception at using (ServiceHost host = new ServiceHost(typeof(HelloService.HelloService))) in the below code Exception : Only an absolute URI can be used as a base address WCF Host Application class Program { static void Main() { using (ServiceHost host = new ServiceHost(typeof(HelloService.HelloService))) { host.Open(); Console.WriteLine("Service Started"); Console.ReadLine(); } } } Contract Implementation public class HelloService : IHelloService { public string

How do I use code contracts in .NET 4.0 without making my code look cluttered?

廉价感情. 提交于 2019-12-14 00:19:40
问题 I have started using Code Contracts and have found that it makes it difficult to immediately spot the 'guts' of a method. Take this (very simple) example: public static void UserAddNew(string domain, string username, string displayName) { Contract.Assert(!string.IsNullOrWhiteSpace(domain)); Contract.Assert(!string.IsNullOrWhiteSpace(username)); Contract.Assert(!string.IsNullOrWhiteSpace(displayName)); LinqDal.User.UserAddNew(domain, username, displayName); } Now I'm tempted to put the

WCF - multiple service contracts using pretty same data contracts

99封情书 提交于 2019-12-07 01:30:52
问题 I have a new question for WCF gurus. So, I have a class User which is close to the 'User' representation from the DB which I use for database operations. Now, I would like to have 2 different service contracts that use this class as data contract, but each in their own way... I mean, public class DBLayer { void InsertUsers(List<User> userList) { // both 'PropertyVisibleForService1' and 'PropertyVisibleForService2' // are used HERE to be inserted into their columns } } [DataContract] public

WCF - multiple service contracts using pretty same data contracts

余生长醉 提交于 2019-12-05 06:22:35
I have a new question for WCF gurus. So, I have a class User which is close to the 'User' representation from the DB which I use for database operations. Now, I would like to have 2 different service contracts that use this class as data contract, but each in their own way... I mean, public class DBLayer { void InsertUsers(List<User> userList) { // both 'PropertyVisibleForService1' and 'PropertyVisibleForService2' // are used HERE to be inserted into their columns } } [DataContract] public class User { [DataMember] public string PropertyVisibleOnlyForService1{...} [DataMember] public string

How do I use code contracts in .NET 4.0 without making my code look cluttered?

只愿长相守 提交于 2019-12-04 03:45:21
I have started using Code Contracts and have found that it makes it difficult to immediately spot the 'guts' of a method. Take this (very simple) example: public static void UserAddNew(string domain, string username, string displayName) { Contract.Assert(!string.IsNullOrWhiteSpace(domain)); Contract.Assert(!string.IsNullOrWhiteSpace(username)); Contract.Assert(!string.IsNullOrWhiteSpace(displayName)); LinqDal.User.UserAddNew(domain, username, displayName); } Now I'm tempted to put the contracts in a region, so that they can be hidden away, but then I'm concerned that I'm losing a nice

WCF - handle versioning

心已入冬 提交于 2019-11-29 14:48:06
If I need to go from this service contract: [ServiceContract(Namespace="http://api.x.com/Svc1")] public interface IService1 { [OperationContract(Name = "AddCustomer")] bool AddCustomer(DTOCustomer1 customer); } to this: [ServiceContract(Namespace="http://api.x.com/Svc1")] public interface IService1 { [OperationContract(Name = "AddCustomer")] bool AddCustomer(DTOCustomer2 customer); } and according to this good article: Versioning WCF I understand that when data contract is changed there is a need of defining a new vs of data contract in new namespace followed by defining a new vs of service

WCF - handle versioning

北战南征 提交于 2019-11-28 08:15:06
问题 If I need to go from this service contract: [ServiceContract(Namespace="http://api.x.com/Svc1")] public interface IService1 { [OperationContract(Name = "AddCustomer")] bool AddCustomer(DTOCustomer1 customer); } to this: [ServiceContract(Namespace="http://api.x.com/Svc1")] public interface IService1 { [OperationContract(Name = "AddCustomer")] bool AddCustomer(DTOCustomer2 customer); } and according to this good article: Versioning WCF I understand that when data contract is changed there is a