// WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml"; [OperationContract Guid AddEmployee(Employee employee) { return Guid.NewGuid(); } [OperationContract public void UpdateEmployee(Employee employee) { return; } [OperationContract // WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml"; [OperationContract Guid AddEmployee(Employee employee) { return Guid.NewGuid(); } [OperationContract
FullTimeEmployee))] 3 [ServiceContract] 4 public interface IEmployeeService 5 { 6 [OperationContract ] 7 Employee GetEmployee(int id); 8 [OperationContract] 9 void SaveEmployee (Employee emp); 10 } ServiceKnownType 还是这种,但他用来可以用来修饰OperationContract,当用来修改Operation的时候,他只对当前Operation ServiceKnownType(typeof(FullTimeEmployee))] 4 [ServiceKnownType(typeof(PartTimeEmployee))] 5 [OperationContract ] 6 Employee GetEmployee(int id); 7 [OperationContract] 8 void SaveEmployee(Employee
(IsOneWay=true)] void Clear(); [OperationContract(IsOneWay = true)] void AddTo (double n); [OperationContract(IsOneWay = true)] void SubtractFrom(double n); [OperationContract(IsOneWay = true)] void MultiplyBy(double n); [OperationContract(IsOneWay = true)] void DivideBy(double n); [OperationContract] double Result(); } n1, double n2); [OperationContract] double Multiply(double n1, double n2); [
get; set; } public string ReplyAction { get; set; } } 在我们定义的服务类型里面需要指定一组操作方法,这些操作方法要作为契约的一部分必须应用[OperationContract Name = "CalculatorService", Namespace = "http://www.ainote.cn")] public interface ICalculator1 { [OperationContract (Name = "AddDouble")] double Add(double x, double y); [OperationContract(Name = "AddInt")] int CalculatorCatract",CallbackContract=typeof(ICalculatorCallback))] public interface ICalculator { [OperationContract = "http://www.ainote.cn/CalculatorService/AddDoubleReply")] double Add(double x, double y); [OperationContract
[OperationContract] void insertEmp(Employee emp); 单工模式 单向通信应是指通信只在一个方向进行,即从客户端流向服务。 [OperationContract(IsOneWay=true)] void insertEmp(Employee emp); 双工模式 双工模式的特点是,无论使用单向消息发送还是请求/答复消息发送方式 SessionMode.Required, CallbackContract=typeof(IServiceDuplexCallback))] public interface IServiceClass { [OperationContract (IsOneWay = true)] void AddNumber(); } public interface IServiceDuplexCallback { [OperationContract
] 23: int GetNumberOfUsersOnline(); 24: [OperationContract] 25: string GetPassword(string username, string answer); 26: [OperationContract(Name="GetUserByName")] ] 31: string GetUserNameByEmail(string email); 32: [OperationContract] 33: string ResetPassword(string username, string answer); 34: [OperationContract] 35: ); 40: [OperationContract] 41: MembershipConfigData GetMembershipConfigData();
person"></param> /// <param name="welcome"></param> /// <returns></returns> [OperationContract person"></param> /// <param name="welcome"></param> /// <returns></returns> [OperationContract person"></param> /// <param name="welcome"></param> /// <returns></returns> [OperationContract person"></param> /// <param name="welcome"></param> /// <returns></returns> [OperationContract person"></param> /// <param name="welcome"></param> /// <returns></returns> [OperationContract
1: [ServiceContract] 2: public interface IServiceContract1 3: { 4: [OperationContract] ProtectionLevel = ProtectionLevel.None)] 8: public interface IServiceContract2 9: { 10: [OperationContract 1: [ServiceContract] 2: public interface ICalculator 3: { 4: [OperationContract(ProtectionLevel = ProtectionLevel.Sign)] 5: double Add(double x, double y); 6: [OperationContract(ProtectionLevel (ProtectionLevel = ProtectionLevel.Sign)] 5: double Add(double x, double y); 6: [OperationContract
[ServiceContract(Name = "IHelloService")] public interface IHelloServiceChanged { [OperationContract ServiceContract 特性用来定义类的名字,里面的OperationContract用来定义方法的名字,如果某天我们改变了方法的名字,又不想让客户端重新引用,只需要定义OperationContract
项目中有一个wcf供jquery调用,wcf示例代码如下:
/**////
summary>
/// 添加 or 修改
///
/// <param name="gb"></param>
[OperationContract ///
3: { 4: [ServiceContract] 5: public interface ICalculator 6: { 7: [OperationContract ] 8: void Add(double x); 9: [OperationContract] 10: void Subtract(double x); 11: [OperationContract] 12: void Multiply(double x); 13: [OperationContract ] 14: void Divide(double x); 15: [OperationContract] 16: double GetResult
namespace ContractInterface { [ServiceContract] public interface IContractManager { [ OperationContract namespace ContractInterface { [ServiceContract] public interface IContractManager { [ OperationContract ] List<Contract> GetContracts(); [OperationContract ] MyCollection<Contract> GetContract();
( SessionMode=SessionMode.Required ) ] public interface IPerCall { [OperationContract ] int AddMethod(int a, int b); [OperationContract] int AddMethod1(int a, int b); [OperationContract] string GetInstanceId();//获取实例Id [OperationContract] int GetInstanceCount(); //获取实例数 [OperationContract] int GetOperationCount(); //
3: { 4: [ServiceContract] 5: public interface ICalculator 6: { 7: [OperationContract ] 8: void Add(double x); 9: [OperationContract] 10: void Subtract(double x); 11: [OperationContract] 12: void Multiply(double x); 13: [OperationContract ] 14: void Divide(double x); 15: [OperationContract] 16: double GetResult
] 6: TimeSpan Renew(); 7: 8: [OperationContract(IsOneWay = true)] 9: void OnSessionKilled(SessionInfo sessionInfo); 10: 11: [OperationContract(IsOneWay = true typeof(ISessionCallback))] 4: public interface ISessionManagement 5: { 6: [OperationContract ] 10: void EndSession(Guid sessionID); 11: 12: [OperationContract] 13: IList<SessionInfo> GetActiveSessions(); 14: 15: [OperationContract] 16: void
上文中的契约定义可以被重新设计: [ServiceContract(SessionMode=SessionMode.Required)] public interface Box { [OperationContract (IsInitiating=true,IsTerminating=false)] void Open(int boxId); [OperationContract(IsInitiating = false, IsTerminating = false)] int GetTotalFrenchletter(); [OperationContract(IsInitiating
Justin Smith 《Twitter WCF Client》 下面我们来看一个简单的例子: [ServiceContract] public interface IService { [OperationContract ] [WebGet] string EchoWithGet(string s); [OperationContract] [WebInvoke] string
给OperationContract 修饰的Divide方法加上FaultContract特性修饰。表明这个方法可能会抛DivideByZeroFault。 public interface ICalculatorService { [FaultContract(typeof(DivideByZeroFault))] [OperationContract
Apply [WebGet] to the operation contract to make it RESTful. e.g. public interface ITestService { [OperationContract for SOAP and XML [ServiceContract(Namespace = "http://test")] public interface ITestService { [OperationContract