标签:
在上一篇中讲解了,如何让一个WCF服务实现多个WCF数据契约,本篇介绍一个数据契约上的Name属性。先看一下,废话不多说,先看一下Demo。
1、数据契约
<span style="font-family:SimSun;font-size:18px;">using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace HelloService
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IHelloService”。
[ServiceContract(Name="IHello")]
public interface IHelloService
{
[OperationContract]
string GetMessage(string name);
}
}
</span>我们看一下契约最终生成的WSDL文档。
<span style="font-family:SimSun;font-size:18px;">-<wsdl:portType name="Ihello"> -<wsdl:operation name="GetMessage"> <wsdl:input message="tns:Ihello_GetMessage_InputMessage" wsaw:Action="http://tempuri.org/Ihello/GetMessage"/> <wsdl:output message="tns:Ihello_GetMessage_OutputMessage" wsaw:Action="http://tempuri.org/Ihello/GetMessageResponse"/> </wsdl:operation> </wsdl:portType></span>
2、小结
本篇简单的介绍了数据契约的一个Name属性,利用此属性就可以做到,在不中断客户端的情况下,更改数据契约。下一篇讲解:WCF数据契约和数据成员
How to make changes to wcf service without breaking clients
标签:
原文地址:http://blog.csdn.net/luckyzhoustar/article/details/46300673