积极答复者
手机端添加WCF实例化client时出现keynotfound错误

问题
答案
-
在不同应用程序类型中,不一定支持所有的binding,像windows phone貌似只支持basicHttpBinding,我当是在服务端使用的是wsHttpBinding,所以引用时不能生成完整的客户端config文件,所以也就出现keynotFound异常
- 已标记为答案 bianchunlei 2012年4月17日 0:16
全部回复
-
本来ServiceReference.ClientConfig文件里只有</configuration>,不知道出了什么问题,自己手动更改该文件如下:
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
maxBufferSize="65536" maxReceivedMessageSize="65536"
textEncoding="utf-8">
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<client>
<!--http://localhost/wcf/Service1.svc是指WCF服务的地址-->
<endpoint address="http://localhost/PhoneUserService"
bindingConfiguration="BasicHttpBinding_IService1"
binding="wsHttpBinding"
contract="PhoneUserService.IPhoneUserService" />
</client>
</system.serviceModel>
</configuration>出现错误:wsHttpBinding无效,应为可能可能元素列表:basicHttpBinding、customBinding。那服务端就不能使用wsHttpbinding了吗?
-
添加Wcf引用后还出现以下警告:
警告 1 自定义工具警告: Endpoint 'WSHttpBinding_IPhoneUserService' at address 'http://localhost/PhoneUserService' is not compatible with Silverlight 3. Skipping...
警告 2 自定义工具警告: No endpoints compatible with Silverlight 3 were found. The generated client class will not be usable unless endpoint information is provided via the constructor.
-
检查一下你的配置里 是否有这个定义 WSHttpBinding_IPhoneUserService
Frank Xu Lei--谦卑若愚,好学若饥
[老徐的网站]:http://www.frankxulei.com/[老徐的博客]:http://54peixun.com/Author/frankxulei
微软WCF中文技术论坛
微软WCF英文技术论坛
Windows Azure中文技术论坛 -
在不同应用程序类型中,不一定支持所有的binding,像windows phone貌似只支持basicHttpBinding,我当是在服务端使用的是wsHttpBinding,所以引用时不能生成完整的客户端config文件,所以也就出现keynotFound异常
- 已标记为答案 bianchunlei 2012年4月17日 0:16