WCF Rest Json

1、定义ServiceContract及实现

WCF Rest Json
    [ServiceContract]
    public interface IMemberService
    {
        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/create", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
        string CreateMember(Member member);

        [OperationContract]
        [WebGet(UriTemplate = "all")]
        string GetAll();
        // TODO: 在此添加您的服务操作
    }
WCF Rest Json

2、svc文件

WCF Rest Json
<%@ServiceHost language=c# Debug="true" Service="WebApplication1.MemberService" Factory="System.ServiceModel.Activation.WebServiceHostFactory"%>
WCF Rest Json

3、Fiddler测试

WCF Rest Json
Request Headers:

User-Agent: Fiddler
Content-Type: application/json;charset=UTF-8
Host: localhost:4087
Content-Length: 45


RequestBody:
{"member":{"ID":"Brett","Name":"McLaughlin"}}
WCF Rest Json

 

WCF Rest Json,布布扣,bubuko.com

WCF Rest Json

上一篇:自动生成网页缩略图


下一篇:jsp中如何设置使用FCKeditor(转自CSDN)