• 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:通过自我寄宿的方式寄宿服务:

  • 相关阅读:
    spring mvc 参数校验
    spring-boot 配置jsp
    java 多线程之取消与关闭
    spring transaction 初识
    java 读取环境变量和系统变量的方法
    每天一命令 git checkout
    每天一命令 git stash
    每天一命令 git reset
    log4j2配置详解
    专业名词及解释记录
  • 原文地址:https://www.cnblogs.com/netact/p/2093232.html
Copyright © 2020-2023  润新知