有没有办法在Windows Phone中使用我们现有的WCF服务? [英] Is there a way to Consume our existing WCF service in Windows Phone?

查看:61
本文介绍了有没有办法在Windows Phone中使用我们现有的WCF服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们现有的WCF服务是使用
NetTcpBinding协议。此wcf服务返回客户端可以使用的接口。 
我们使用Windows窗体客户端使用这些接口。问题是我们现在想要在Windows Phone和SilverLight中使用这些接口。 
我们无法在Windows Phone中添加接口和公共库,因为这些程序集是使用Windows库构建的,或者这些程序集是Windows库。

Our existing WCF service is a windows service application that uses NetTcpBinding protocol. This wcf service returns Interface (s) that can be consumed by the clients.  We use these interfaces using windows forms clients. The problem is that we now want to consume these interfaces in Windows Phone and SilverLight.  We cannot add the interfaces and the Common libraries in windows phone since these assemblies were built using the Windows Libraries, or these assemblies are Windows libraries.

以下是代码和解释:

服务器(WCF服务):

Server (WCF Service):

ServiceHost sh =
new ServiceHost typeof (Company.BusinessFacade.Factories。 CompanySystem ));

ServiceHost sh = new ServiceHost(typeof(Company.BusinessFacade.Factories.CompanySystem));

sh.AddServiceEndpoint(

             
typeof (Company.Common.Interfaces。 ICompanySystem ), 

              typeof(Company.Common.Interfaces.ICompanySystem), 

             
NetTcpBinding (),

              new NetTcpBinding(),

            
new EndpointAddress (" net.tcp:// Server:8090 / ICompanySystem" ));  

             new EndpointAddress("net.tcp://Server:8090/ICompanySystem")); 

客户端(Windows窗体):

Clients (Windows Forms):

CompanySystem companySystem =
new ChannelFactory < Company.Common .Interfaces。 ICompanySystem >(

CompanySystem companySystem = new ChannelFactory<Company.Common.Interfaces.ICompanySystem>(

                                      
new NetTcpBinding (),new EndpointAddress (" net.tcp:// Server:8090 / ICompanySystem"))。。CreateChannel();

                                      new NetTcpBinding() ,new EndpointAddress("net.tcp://Server:8090/ICompanySystem")).CreateChannel();

问题(在Windows手机中):

Problems (in windows phone):

Windows Phone中的问题是程序集,
Company.BusinessFacade.Factories。 CompanySystem和
Company.Common.Interfaces。在Windows Phone中无法识别ICompanySystem,因为这些程序集是使用Windows库构建的。我也无法将这些附件添加到Windows Phone项目中。但问题是我是否使用Windows Phone构建这些
程序集那会有用吗?但是,如果我构建它们,那么程序集名称'CompanySystem'依赖于其他程序集等等,这意味着我应该在Windows Phone中再次构建所有的esisting程序集!

The problem in windows phone is that the assemblies, that are Company.BusinessFacade.Factories.CompanySystem and Company.Common.Interfaces.ICompanySystem cannot be recognized in Windows Phone since these assemblies built using Windows libraries. I cannot add these addemblies to windows phone project as well. But the question is if I build these assemblies using the Windows Phone again, will that work? But, If I do build them, still the assembly name 'CompanySystem' is dependent on other assemblies and so on which means I should build all the esisting assemblies again in Windows Phone!

是否有更好的方法或方法来消费' CompanySystem'assembly
如何构建Windows Phone或SilverLight应用程序以连接到此WCF服务?我应该做哪些更改?

这是结构!

Mike

推荐答案

是否可以在WCF服务中实现Http绑定?这样你就可以了可以通过WebClient()在Windows手机上轻松访问它。 

is it possible to implement a Http Binding in your WCF Service? That way you could easily access it on the Windows phone via a WebClient(). 

您是否尝试通过"添加服务参考"添加WCF服务以让VS为您生成代理? ( http://support.microsoft.com/kb/2425652)  (< a href ="http://blogs.msdn.com/b/andypennell/archive/2010/09/20/using-wcf-on-windows-phone-7-walk-through.aspx)"> http:// blogs.msdn.com/b/andypennell/archive/2010/09/20/using-wcf-on-windows-phone-7-walk-through.aspx)
- >我希望我没有误解你的问题:)

Have you tried adding your WCF Service via "Add Service Reference" to let VS generate a Proxy for you? (http://support.microsoft.com/kb/2425652) (http://blogs.msdn.com/b/andypennell/archive/2010/09/20/using-wcf-on-windows-phone-7-walk-through.aspx) -> I hope i didn't misunderstand your Problem :)


这篇关于有没有办法在Windows Phone中使用我们现有的WCF服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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