This is the second of six tasks required to create a basic Windows Communication Foundation (WCF) service and a client that can call the service. For an overview of all six tasks, see the Getting Started Tutorial topic.

The next step in creating a WCF application is to implement the service interface. This involves creating a class called CalculatorService that implements the user-defined ICalculator interface..

To implement a WCF service contract

  • Open the Service1.cs or Service1.vb file and add the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text; namespace GettingStartedLib
{ public class CalculatorService : ICalculator
{
public double Add(double n1, double n2)
{
double result = n1 + n2;
Console.WriteLine("Received Add({0},{1})", n1, n2);
// Code added to write output to the console window.
Console.WriteLine("Return: {0}", result);
return result;
} public double Subtract(double n1, double n2)
{
double result = n1 - n2;
Console.WriteLine("Received Subtract({0},{1})", n1, n2);
Console.WriteLine("Return: {0}", result);
return result;
} public double Multiply(double n1, double n2)
{
double result = n1 * n2;
Console.WriteLine("Received Multiply({0},{1})", n1, n2);
Console.WriteLine("Return: {0}", result);
return result;
} public double Divide(double n1, double n2)
{
double result = n1 / n2;
Console.WriteLine("Received Divide({0},{1})", n1, n2);
Console.WriteLine("Return: {0}", result);
return result;
}
}
}

Each method implements the calculator operation and writes some text to the console to make testing easier.

Step2 - How to: Implement a Windows Communication Foundation Service Contract的更多相关文章

  1. How to: Implement a Windows Communication Foundation Service Contract

    This is the second of six tasks required to create a basic Windows Communication Foundation (WCF) se ...

  2. How to: Define a Windows Communication Foundation Service Contract

    This is the first of six tasks required to create a basic Windows Communication Foundation (WCF) app ...

  3. Step1 - How to: Define a Windows Communication Foundation Service Contract

    https://msdn.microsoft.com/en-us/library/ms731835.aspx This is the first of six tasks required to cr ...

  4. How to: Host and Run a Basic Windows Communication Foundation Service

    This is the third of six tasks required to create a Windows Communication Foundation (WCF) applicati ...

  5. Step3 - How to: Host and Run a Basic Windows Communication Foundation Service

    This is the third of six tasks required to create a Windows Communication Foundation (WCF) applicati ...

  6. Windows Communication Foundation (WCF)和Windows CardSpace的示例程序

    微软公司昨天发布了一个Windows Communication Foundation (WCF)和Windows CardSpace的示例程序包,内容极为丰富,从最简单的Hello World到复杂 ...

  7. How to: Create a Windows Communication Foundation Client

    How to: Create a Windows Communication Foundation Client To create a Windows Communication Foundatio ...

  8. 【翻译习作】 Windows Workflow Foundation程序开发-第一章02

    1.2      Windows Workflow概览 微软的Windows Workflow Foundation(简称WF)是.NET框架3.0版的一部分..NET3.0其它主要部分是Window ...

  9. Workflow-Microsoft:Windows Workflow Foundation

    ylbtech-Workflow-Microsoft:Windows Workflow Foundation 1. Windows Workflow Foundation返回顶部 1.1. Windo ...

随机推荐

  1. idea的热部署

    1:先找到你要热部署的tomcat之后 ,在设置tomcat时  先选择 server,里面有On 'Update' action ()  和 On frame deactivation 这两项  都 ...

  2. Echats

    网址:https://www.echartsjs.com 1.特性 ECharts,一个使用 JavaScript 实现的开源可视化库,可以流畅的运行在 PC 和移动设备上,兼容当前绝大部分浏览器(I ...

  3. Hadoop Map/Reduce

    Hadoop Map/Reduce是一个使用简易的软件框架,基于它写出来的应用程序能够运行在由上千个商用机器组成的大型集群上,并以一种可靠容错的方式并行处理上T级别的数据集.一个Map/Reduce ...

  4. DelayQueue详解

    一.DelayQueue是什么 DelayQueue是一个无界的BlockingQueue,用于放置实现了Delayed接口的对象,其中的对象只能在其到期时才能从队列中取走.这种队列是有序的,即队头对 ...

  5. java 注解 Annontation

    什么是注解? 对于很多初次接触的开发者来说应该都有这个疑问?Annontation是Java5开始引入的新特征,中文名称叫注解.它提供了一种安全的类似注释的机制,用来将任何的信息或元数据(metada ...

  6. HDU 4285 circuits( 插头dp , k回路 )

    circuits Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. NGUI的HUD Text的扩展插件学习--(UIFollowTarget)的使用

    一,我们先导入NGUI_HUD_Text_v1.11包,导入包后会在项目生成一个这样的文件夹 二,我们添加一个cube,给cube添加一个空的游戏对象 二,我们使添加一个label,然后给label添 ...

  8. MicroPython 的优势

    定位的场景 MicroPython 在设计上最初就是为了嵌入式微处理器运行,例如在 nRF51822 (256kB flash + 16kB RAM) 的芯片上也可以运行起来,也有人肾得慌在 STM3 ...

  9. referenceQueue用法

    何为referenceQueue 在java的引用体系中,存在着强引用,软引用,虚引用,幽灵引用,这4种引用类型.在正常的使用过程中,我们定义的类型都是强引用的,这种引用类型在回收中,只有当其它对象没 ...

  10. MySQL第五天——日志

    日志 log_error(错误日志) 用于记录 MySQL 运行过程中的错误信息,如,无法加载 MySQL数据库的数据文件,或权限不正确等都会被记录在此. 默认情况下,错误日志是开启的,且无法禁止. ...