WCF Rest Json

2020-11-24 10:53

阅读:659

标签:style   blog   class   code   java   color   

1、定义ServiceContract及实现

soscw.com,搜素材
    [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: 在此添加您的服务操作
    }
soscw.com,搜素材

2、svc文件

soscw.com,搜素材
"true" Service="WebApplication1.MemberService" Factory="System.ServiceModel.Activation.WebServiceHostFactory"%>
soscw.com,搜素材

3、Fiddler测试

soscw.com,搜素材
Request Headers:

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


RequestBody:
{"member":{"ID":"Brett","Name":"McLaughlin"}}
soscw.com,搜素材

 

WCF Rest Json,搜素材,soscw.com

WCF Rest Json

标签:style   blog   class   code   java   color   

原文地址:http://www.cnblogs.com/happytime/p/3704343.html


评论


亲,登录后才可以留言!