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

  • 相关阅读:
    Linux找回root密码
    关于Linux的随笔笔记
    需求征集系统进度03
    需求征集系统进度02
    需求征集系统进度01
    第六周总结
    阅读笔记03
    第一周总结
    第五周总结
    阅读笔记02
  • 原文地址:https://www.cnblogs.com/netact/p/2093232.html
Copyright © 2011-2022 走看看