wcf service library

创建wcf服务库的时候,系统自动生成的代码

 // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        // TODO: 在此添加您的服务操作
    }

    // 使用下面示例中说明的数据约定将复合类型添加到服务操作。
    // 可以将 XSD 文件添加到项目中。在生成项目后,可以通过命名空间“WcfServiceLib.ContractType”直接使用其中定义的数据类型。
    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }

服务实现

// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“Service1”。
    public class Service1 : IService1
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {
            if (composite == null)
            {
                throw new ArgumentNullException("composite");
            }
            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }
    }
时间: 2024-08-29 09:17:58

wcf service library的相关文章

如何创建一个AJAX-Enabled WCF Service

  原创地址:http://www.cnblogs.com/jfzhu/p/4041638.html 转载请注明出处   前面的文章中介绍过<Step by Step 创建一个WCF Service >以及<如何使用WCF的Trace与Message Log功能>,本文介绍如何创建一个AJAX-Enabled WCF Service. (一)创建一个WCF AJAX-enabled service 1. 打开Visual Studio 2012,创建一个ASP.NET Empty

ASP.NET MVC提交一个较复杂对象至WCF Service

前一篇<jQuery.Ajax()执行WCF Service的方法>http://www.cnblogs.com/insus/p/3727875.html 我们有练习在asp.net mvc应用程序中,POST 数据去wcf service并执行方法.本篇的练习是提交较复对象至wcf service执行方法.前一篇中,它只传递两个参数.如果我们平时开发,需要传递过多的参数时,那得需要写很多个参数.因此产生此篇,把较多个参数,创建为一个对象.然后只传递这个对象至wcf service即可. 下面

用JavaScript调用WCF Service

原文:用JavaScript调用WCF Service 原创地址:http://www.cnblogs.com/jfzhu/p/4039604.html 转载请注明出处 前面介绍过<Step by Step 创建一个WCF Service>和<使用WCF的Trace与Message Log功能>,本文介绍一下如何用JavaScript来调用WCF Service. WCF Service的代码如下: IHelloService.cs using System.ServiceMode

WCF Service Configuration Editor的使用

WCF Service Configuration Editor的使用 2014-06-13 通过WCF Service Configuration Editor的配置修改Client端 在上篇文章创建一个简单的WCF程序中, 使用WCF Service Configuration Editor工具生成XML文件来进行WCF的配置,而不是在CS文件中敲代码. 通过WCF Service Configuration Editor的配置 返回 以下是使用WCF Service Configurati

WCF Service Configuration Editor的使用【转】

原文:http://www.cnblogs.com/Ming8006/p/3772221.html 通过WCF Service Configuration Editor的配置修改Client端 参考 在上篇文章创建一个简单的WCF程序中, 通过编码的方式进行终结点的添加和服务行为的定义,但在进行真正的WCF应用开发时,一般会直接是通过配置的方式进行. 对于初学者来说,WCF的配置显得过于复杂,直接对配置文件进行手工编辑不太现实.在这种情况下,可以直接使用VS提供的配置工具WCF Service

MVC应用程序使用Wcf Service

原文:MVC应用程序使用Wcf Service 前一篇Insus.NET有演示过MVC应用程序使用Web Service, 此篇Insus.NET想继续演示Service,不过是WCF Service. 两者实施起来,多少有些不一样. 在Services目录下,创建一个Calculator.svc 服务.创建成功之后,它会生生成一个接口以及一个svc的文件: 在Calculator.svc中,它是实作上面的接口,而且均实现了四个方法: WCF Service创建好之后,正常的话,它能浏览: 下面

不写画面的网页程序设计,Web API、Web Service、WCF Service

客户有一个系统,经常要连上我方,查询数据 以前的作法是给对方一个账号,让他可以连上我们的DB来查询. 所以,早期的同仁,真的给他们DB链接字符串 客户的Windows程序.网站就真的靠这么危险的方式,连上我们公司的DB. 但怎么想都觉得危险,而且...... 如果对方SQL指令乱下,把效能搞得更烂,岂不是惨兮兮? 如果对方不小心,配置文件被偷走,看到我方DB Connection String怎么办? 几年前的 Internet还没有那么大的带宽,所以还得种种限制,避免他们一次查询太多数据 我接

How to make a simplest WCF service work on Win7 with VS2010

You know as a beginner to learn WCF, the first thing is to make a simplest WCF service work like a classic "Hello World" console application. Now I will introduce the steps by following: 1.Create a "WCF Application Service" like this:

Fixing common issues when hosting a .NET 4.0 WCF service in IIS 7

http://sandrinodimattia.net/fixing-common-issues-when-hosting-a-net-4-0-wcf-service-in-iis-7/ Until today I never had to host a WCF service in IIS… I always prefered using a ServiceHost in a Windows Service. Before getting my service up and running I