WCF中操作契约 BodyStyle和XML, Json格式的学习
来源:互联网 发布:家庭农场管理软件源码 编辑:程序博客网 时间:2024/06/06 02:05
今天研究了一下在之前在帖子Android访问WCf得到的奇怪JSON中提到的问题, 发现跟其于操作契约中设置的BodyStyle有关, 详细参阅[WCF REST] Web消息主体风格(Message Body Style).
在这里做一下记录:
endpointBehaviors
<behavior name="webScript"><enableWebScript /></behavior>
<behavior name ="webHTTP"><webHttp/></behavior>endpoint
<!--原来是webScript-->
<endpoint address="" binding="webHttpBinding" contract="Host.IAndroidServices" behaviorConfiguration="webHTTP"> <identity> <dns value="localhost"/> </identity> </endpoint>
操作契约
[OperationContract] [WebInvoke( BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] RetUserInform logIn(string userID, string PWD);
操作契约实现
#region IAndroidServices Members logIn public RetUserInform logIn(string userID, string PWD) { Console.WriteLine("logIn has bean satared"); RetUserInform n = new RetUserInform(); n.Userid = 123456; n.Functions = "asdfads"; n.UserAreaCode = "012"; n.FinalDate = "afd"; return n; } #endregion之前得到格式为
{"d":{"__type":"RetUserInform:#Host","FinalDate":"afd","Functions":"asdfads","UserAreaCode":"012","Userid":123456}}
的JSON串是由于对Response的包装导致的, 作出如上修改后得到
{"FinalDate":"afd","Functions":"asdfads","UserAreaCode":"012","Userid":123456}
一切正常.
- WCF中操作契约 BodyStyle和XML, Json格式的学习
- WCF服务契约和操作重载
- WCF契约的简介(服务契约、数据契约和消息契约)
- WCF学习(2)- 契约
- 深入学习WCF-契约
- WCF学习(二):契约
- WCF契约 学习备忘
- WCF契约设计: 服务契约,数据契约和消息契约
- Ajax中XML和JSON格式的优劣比较
- Ajax中XML和JSON格式的优劣比较
- Ajax中XML和JSON格式的优劣比较
- Ajax中XML和JSON格式的优劣比较
- Ajax中XML和JSON格式的优劣比较
- Ajax中XML和JSON格式的优劣比较
- Ajax中XML和JSON格式的优劣比较
- (转)Ajax中XML和JSON格式的优劣比较
- Ajax中XML和JSON格式的优劣比较
- Ajax中XML和JSON格式的优劣比较
- Android 怎样获得手机信息
- java中实现多态的机制是什么?
- 求1000以内偶数的和
- C++ 补全插件
- 程序设计语言
- WCF中操作契约 BodyStyle和XML, Json格式的学习
- 学习笔记之(1)
- Flex 中点击Tree 获取点中的值
- Android传感器---Environment Sensor
- 关于项目选择
- abstract的method是否可同时是static,是否可同时是native,是否可同时是synchronized?
- Android 时区设置对时间显示的影响
- 帧缓冲设备驱动的模块加载/卸载及平台驱动的探测/移除函数的模板
- 关于 Demo_Ocean 例子的分析(修改cg中的参数)