1、新建WCF服务
2、主要有三个文件的
IService1
Service1
App.config
以下时
IService1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace AuthorityControl
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "DoWork", ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped)]
string DoWork();
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "DoWorkData", ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped)]
string DoWorkData();
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "DoWorkParam/?data={data}", ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
string DoWorkParam(string data);
}
}