WCF客户端差异 [英] WCF Client Differences

查看:156
本文介绍了WCF客户端差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我刚开始使用WCF,我提供了一项服务,并将其上传到了我的共享主机上.(经过一番摆弄配置后,关闭了安全性),然后转到service.svc,它显示元数据页面.我运行svcutil [address]并获得一个代理类,可以通过控制台程序使用它.一切正常,我可以将两个数字加在一起!

但是...
这次我在Silverlight中尝试添加服务引用,现在当我使引用无效时,我得到KeyNotFoundException.在使用Silverlight中的WCF服务时,我需要了解什么区别?

Hi folks,

I''ve being starting out on WCF, I made a service and uploaded to my shared hosting.(after a bit of fiddling with configs, switching off security) I then navigate to the service.svc and it shows the metadata page. I run svcutil [address] and get a proxy class which I can consume through my console program. It all works fine I can add two numbers together!

However...
I try it in Silverlight this time adding a service reference, now when I instatiate the reference I get a KeyNotFoundException. What are the differences I need to be aware of when use a WCF service from silverlight?

推荐答案

科林,

这个问题使我发疯了在星期五,所以我想让您知道答案:)

您需要做的是在包含客户端服务参考的Silverlight应用程序中打开ServiceReferences.ClientConfig文件.当我这样做时,我注意到它只包含一个空标记< configuration/>.

然后,我要做的是在宿主Web应用程序项目(其中包含要删除的Web Service)中打开Web.config文件.被消耗).找到< endpoint>您尝试向Silverlight应用程序公开的服务底部的条目.将绑定属性更改为"basicHttpBinding".保存文件.

切换回我们之前打开的ServiceReferences.ClientConfig文件,在解决方案资源管理器"中的服务引用"文件夹下,右键单击服务引用,然后选择更新服务引用".您将注意到配置文件现在已正确填充,您现在应该可以使用该服务.

默认绑定似乎是wsHttpBinding,由于某种原因,它不会在ServiceReferences.ClientConfig文件中生成任何代码. .

看看是否可行   [D''Oh]

Peter
Hi Colin,

This problem was driving me mad on Friday so I thought I would let you know the answer :)

What you need to do is open the ServiceReferences.ClientConfig file in your Silverlight application that contains the client Service Reference. When I did this, I noticed it only contained an empty tag <configuration />.

What I then did was open the Web.config file in my host web application project (that contains the Web Service to be consumed). Locate the <endpoint> entry at the bottom for the service you are trying to expose to the Silverlight app. Change the binding attribute to "basicHttpBinding". Save the file.

Switch back to the ServiceReferences.ClientConfig file we opened earlier, in Solution Explorer, under Service References folder right click the service reference and select "Update Service Refeernce". You will notice that the config file is now populated correctly and you should be able to use the service now.

The default binding appears to be wsHttpBinding which for some reason does not generate any code in the ServiceReferences.ClientConfig file.

See if that works   [D''Oh]

Peter


这篇关于WCF客户端差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆