WCF学习心得--客户端获取服务端自定义类数据
2013-10-12 11:02
489 查看
因项目需求,需要一个WCF服务,赶鸭子上架吧!下面直接切入正题!
首先创建WCF应用程序,具体如何创建就不赘述了,网上一大篇,我主要说说自己遇到的问题
问题一:超时问题,在最后获取数据的时候突然提示服务超时,服务已断开
解决:配置文件添加:
当然你也可以在代码中修改WSHttpBinding对象的一些属性
问题二:解决上述问题之后又出现了新问题,在服务端可以获取得到数据,但是到了客户端总是空,然后准备测试数据,在服务端只给一个int型的变量,客户端获取的到,但是一旦换成自己的自定义类,客户端就获取不到
解决:在服务端和客户端都要有自定义类,代码要一样,另外还要保证两个类的命名空间一致
如:服务端
客户端一样:
OK~~结果如预期出来!!
后来验收的时候又出现了个问题:客户端还是无法获取服务端的数据,真的不知道是哪儿的问题,程序也没动过,,,,,找问题呀找问题,,,最后是因为客户端的时间和服务端的时间不一致,在网上也看到类似的说法,如果客户端和服务端的时间差超过5分钟,通信将失败,,,,???????
首先创建WCF应用程序,具体如何创建就不赘述了,网上一大篇,我主要说说自己遇到的问题
问题一:超时问题,在最后获取数据的时候突然提示服务超时,服务已断开
解决:配置文件添加:
<bindings> <wsHttpBinding> <binding name="BindConfig" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="None"> <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /> <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" /> </security> </binding>
当然你也可以在代码中修改WSHttpBinding对象的一些属性
问题二:解决上述问题之后又出现了新问题,在服务端可以获取得到数据,但是到了客户端总是空,然后准备测试数据,在服务端只给一个int型的变量,客户端获取的到,但是一旦换成自己的自定义类,客户端就获取不到
解决:在服务端和客户端都要有自定义类,代码要一样,另外还要保证两个类的命名空间一致
如:服务端
[DataContract(Namespace = "Rostering.BO")] [Serializable] public class NewAttendancePlan { [DataMember] public int AttendancePlan_Id { get; set; } }
客户端一样:
[DataContract(Namespace = "Rostering.BO")] [Serializable] public class NewAttendancePlan { [DataMember] public int AttendancePlan_Id { get; set; } }
OK~~结果如预期出来!!
后来验收的时候又出现了个问题:客户端还是无法获取服务端的数据,真的不知道是哪儿的问题,程序也没动过,,,,,找问题呀找问题,,,最后是因为客户端的时间和服务端的时间不一致,在网上也看到类似的说法,如果客户端和服务端的时间差超过5分钟,通信将失败,,,,???????
相关文章推荐
- WCF学习心得--客户端获取服务端自定义类数据
- 客户端获取服务端自定义类数据 z
- WCF客户端获取服务端异常[自定义异常]
- [Silverlight学习笔记]关于利用WCF RIA Service进行通信并在客户端获取数据
- WCF学习心得----(六)数据协定
- 一个Android客户端,调用WCF服务获取数据
- android 集合SSH服务端实现登录并保持session使客户端在登陆后能够获取服务端数据
- JS客户端获取服务端返回数据方法总结
- 【转载】Java数据接口编写简单例子,Java Json解析,服务端接口输出Json数据,客户端通过HTTP获取接口Json数据,作者:Jaiky_杰哥
- Android 客户端从服务端获取json数据并解析的实现代码
- Java Socket学习(二)——客户端服务端相互传输数据
- CSLA.Net 学习 - WCF服务端与客户端配置
- Java 服务端 使用WebService 模拟客户端从第三个平台获取数据
- 视频十四学习心得,跳转语句与自定义数据类型
- 学习笔记之 WCF安全(6) 数字证书 自定义证书验证+ 客户端 证书验证(wshttpBinding)
- Android客户端之“微服私访”App的系统学习(三)基于 OkHttp和Gson 快速获取解析服务数据
- 【推荐】捕获WCF服务端与客户端产生的通讯数据并分析
- Netty学习心得 netty服务端和客户端的连接
- BT源代码学习心得(十六):客户端源代码分析(实际数据的传输及其速率限制策略)
- WCF学习心得------(六)数据协定