Step2 - 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) 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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Windows Communication Foundation (WCF)和Windows CardSpace的示例程序
微软公司昨天发布了一个Windows Communication Foundation (WCF)和Windows CardSpace的示例程序包,内容极为丰富,从最简单的Hello World到复杂 ...
- How to: Create a Windows Communication Foundation Client
How to: Create a Windows Communication Foundation Client To create a Windows Communication Foundatio ...
- 【翻译习作】 Windows Workflow Foundation程序开发-第一章02
1.2 Windows Workflow概览 微软的Windows Workflow Foundation(简称WF)是.NET框架3.0版的一部分..NET3.0其它主要部分是Window ...
- Workflow-Microsoft:Windows Workflow Foundation
ylbtech-Workflow-Microsoft:Windows Workflow Foundation 1. Windows Workflow Foundation返回顶部 1.1. Windo ...
随机推荐
- Mac016--安装kubernetes(k8s)
一.安装kubernetes(k8s) 参考: http://batizhao.github.io/2018/01/18/Running-Kubernetes-Locally-via-Minikube ...
- sql中的isnull
ISNULL 使用指定的替换值替换 NULL. 语法ISNULL ( check_expression , replacement_value ) 参数check_expression 将被检查是否为 ...
- 【sql server复制】不重新初始化快照的情况下新增表/存储过程/函数等
转发自:https://www.cnblogs.com/datazhang/p/5498789.html sqlserver同步后在不重新初始化快照的情况下新增表 在已有事务复制中,时长 ...
- A*(A_star)搜索总结
\(A^*(A star)\)搜索总结 标签:算法--搜索 阅读体验:https://zybuluo.com/Junlier/note/1299772 定义 先复制一则定义 \(A^*\)算法在人工智 ...
- 3183 RMQ / 贪心(坑成。。)
题意:删去m个数,使剩下的数组成的数最小 题解 :贪心 , RMQ RMQ解法,建st表找,用rmq找最小值的下标,注意点 ,因为最小值是区间最右最小值,所以应该改成 <= 而不是< mi ...
- mybatis-plus&springboot
** 问题1:mybatis 读取不到 mapper映射文件. 如下: ** 如果引用 mybatis-plus 包 <dependency> <groupId>com.bao ...
- vue-cli-webpake搭建和配置
确认创建项目后,后续还需输入一下项目名称.项目描述.作者.打包方式.是否使用ESLint规范代码等等,详见上图.安装顺利执行后会,生成如下文件目录:1.全局化安装cnpm npm install cn ...
- vue.js(17)--vue的组件切换
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Vue实现点击li变色
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- ubuntu16.04安装mysql数据库
安装 sudo apt-get install mysql-server(安装过程中按提示设置root密码) sudo apt-get install mysql-client sudo apt-ge ...