zoukankan      html  css  js  c++  java
  • WCF说明

    1,创建服务契约类 :用接口来实现服务契约

       1: using System.ServiceModel;
       2: namespace Artech.WcfServices.Contracts
       3: {
       4:     [ServiceContract(Name="CalculatorService", Namespace="http://www.artech.com/")]
       5:     public interface ICalculator
       6:     {
       7:         [OperationContract]
       8:         double Add(double x, double y);
       9:  
      10:         [OperationContract]
      11:         double Subtract(double x, double y);
      12:  
      13:         [OperationContract]
      14:         double Multiply(double x, double y);
      15:  
      16:         [OperationContract]
      17:         double Divide(double x, double y);        
      18:     } 
      19: }

    2,创建服务类:用服务类来实现服务契约接口类

       1: using Artech.WcfServices.Contracts;
       2: namespace Artech.WcfServices.Services
       3: {
       4:    public class CalculatorService:ICalculator
       5:     {
       6:         public double Add(double x, double y)
       7:         {
       8:             return x + y;
       9:         }
      10:  
      11:         public double Subtract(double x, double y)
      12:         {
      13:             return x - y;
      14:         }
      15:  
      16:         public double Multiply(double x, double y)
      17:         {
      18:             return x * y;
      19:         }
      20:  
      21:         public double Divide(double x, double y)
      22:         {
      23:             return x / y;
      24:         }
      25:     }
      26: }

    3:通过自我寄宿的方式寄宿服务:

  • 相关阅读:
    Funny Car Racing
    [LDUoj 倍增] 题解
    [HDU7073] Integers Have Friends 2.0 -随机大法好
    【spring】全局异常 globalexception 处理
    【maven】测试
    【spring】spring aop
    jvm常用排错命令
    idea tools
    idea插件
    【maven】搭建maven私服--基于CentOS7.6+docker
  • 原文地址:https://www.cnblogs.com/netact/p/2093232.html
Copyright © 2011-2022 走看看