Fork me on GitHub
WCF返回JSON与传入JSON(普通参数或对象)
{"__type":"Circle:#MyApp.Shapes","x":50,"y":70,"radius":10
执行反序列化时,既能识别截断的名称 (#MyApp.Shapes),也能识别完整的名称 (http://schemas.datacontract.org/2004/07/MyApp.Shapes)。
    2.就是参数格式了.
    
[OperationContract]
[WebInvoke]
public void SetDisputSearch(test dsd)
{
int i = dsd.i;
}
[DataContract]
public class test
{
[DataMember]
public int i { set; get; }
[DataMember]
public int? l { set; get; }
[DataMember]
public int? k { set; get; }
}
上面这样的方法怎么调用呢,这就是本文的重点了,大家一看就明白了.
webSer("/Server/Search.svc/SetDisputSearch", null, { "dsd": { "__type": "test:#""i": 1,"k":0} });
"dsd": { "__type": "test:#""i": 1,"k":0} }其中dsd就是参数名了.后面就是这个对象的信息了.在这个例子里面"__type":"test:#", 不要也能成功的.
 
分类: .NET
posted on 2012-05-09 20:31  HackerVirus  阅读(326)  评论(0编辑  收藏  举报