连接MVVMCross Portable连接到WCF DataService.是否有可能? [英] Connecting MVVMCross Portable connect to WCF DataService. Is it possible?

查看:60
本文介绍了连接MVVMCross Portable连接到WCF DataService.是否有可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要你的建议.我正在VS2012中编写有关二手车经销的工程工作项目.我有一个SQL数据库,WCF DataService,WPF应用程序(已成功连接到WCF),并且也想为其创建移动版本.我选择MVVMCross Portable创建具有一个核心的Mono For Android和WP7应用.而且我在从移动便携式内核连接到WCF DataService时遇到问题,例如:

I need your advice people. I am writing an engineering work project in VS2012 about used car dealership. I have a SQL Database, WCF DataService, WPF application (which is connected succesfuly to WCF) and wanted to create Mobile version for it too. I chose MVVMCross Portable to create Mono For Android and WP7 app with one core. And I have problems here with connecting to my WCF DataService from mobile portable core like:

无法将服务引用添加到指定的OData提要,因为 未为该目标框架安装WCF数据服务.安装 WCF数据服务的受支持版本,请参阅 http://go.microsoft.com/fwlink/?LinkId=253653 .

Unable to add a service reference to the specified OData feed because WCF Data Services is not installed for this target framework. To install a supported version of WCF Data Services, see http://go.microsoft.com/fwlink/?LinkId=253653.

我在互联网上搜索,看来可移植类库尚不支持WCF数据服务.我正在将这个问题写给您,希望对此有任何解决方案.如果没有,我就等吗?

I searched on the internet and it seems that Portable Class Library doesn't support the WCF Data Service yet. I am writing this question to you in hope that there is any solution for this. If not shall I just wait?

  • 或者也许我需要将WCF数据服务更改为可以在mvvmcross便携式计算机上运行的普通WCF服务,但是要更改应用程序中的许多工作,我需要在WPF中做些什么,

  • or perhaps I need to change my WCF Data Service to normal WCF Service that will work on mvvmcross portable but there will be a lot of work to change in app what I have in WPF done,

或者也许我应该回到MVVMCross Master,它没有可移植类库,但是不支持Android与数据服务连接.

or maybe I should get back to MVVMCross Master, that is without portable-class-library, but there is no support for Android to connect with Data Service.

我读了一些有关Simply.OData的内容,但我不知道如何使它成功工作.

I read a little about Simply.OData but I have no idea how to put it to work succesfuly.

谢谢.

推荐答案

我已将MvvmCross应用程序从所有Droid,Touch和WinPhone连接到WCF基本HTTP数据服务(从未尝试过WinRT或WPF-但它们也应该工作)

I've connected MvvmCross applications to WCF Basic HTTP data services from all of Droid, Touch and WinPhone (never tried WinRT or WPF - but they should work too)

但是,您正确地认为WCF代码在不同平台上需要有所不同-这是因为WCF使用的代码不可移植.

You are, however, correct that the WCF code will need to be different on the different platforms - this is because the code WCF uses isn't portable.

我认为有两种基本的解决方法:

I think there are 2 basic choices about how to tackle this:

  1. 将WCF代码包装在可移植界面后面,该界面处理可移植DTO类,并提供用于Get/Send的界面.然后,您需要为每个平台编写一个小型类,该类将便携式DTO映射到非便携式DTO.诸如AutoMapper之类的工具可能会对此有所帮助-尽管我尚未在MonoDroid或WinPhone上尝试过此操作.

  1. Wrap the WCF code behind a portable interface - an interface that deals in Portable DTO classes and that presents an interface for the Get/Send. You'll then need to write a small class for each platform which maps the portable DTO's to/from the non-portable ones. Tools like AutoMapper may help with this - I haven't tried this on MonoDroid or WinPhone though.

在核心中使用文件链接,并为每个平台维护单独的库项目.有关此文件链接方法的示例,请查看 https://github.com/Redth/WshLst/-适用于Azure移动服务而不是WCF-但适用相同的原则.

Use file-linking in your core and maintain separate library projects for each platform. For an example of this file linking approach take a look at https://github.com/Redth/WshLst/ - this was for Azure mobile services rather than WCF - but the same principals apply.

这两种方法都不是完美的-都在开发中投入了精力-但它们仍然希望为您提供一种共享代码并逐步构建应用程序的方法.

Neither of these two approaches is perfect - both put overhead into development - but both still hopefully provide you with a way to share code and build your app moving forwards.

我个人更喜欢方法1-因为它提供了一个干净的接口,可将当前网络堆栈与我的应用程序逻辑分开-并且它为我提供了一种技术路线,以删除WCF并在将来将其替换为WebAPI或服务栈.

I personally prefer approach 1 - as it provides a clean interface separating the current network stack from my app logic - and it provides me with a technical route to removing WCF and replacing it with something like WebAPI or service stack in the future.

在不久的将来,可能会有一个共享的可移植类库配置文件,该配置文件支持MonoTouch和MonoDroid上的某些WCF功能-但是我怀疑这将很快在Wp或WinRT上可用:/

In the near future, there may be a shared Portable Class library profile which supports some WCF functionality across MonoTouch and MonoDroid - but I doubt this will be available at any point soon on Wp or WinRT :/

恐怕对Simple.OData一无所知(对此 https://github. com/simplefx/Simple.OData )-我相信写了很多东西的人,但我不知道他们的dynamic代码在WP和MonoDroid上的工作情况如何.我认为它应该同时适用于两者-但是依赖Reflection.Emit的任何代码都可能存在问题.

I'm afraid don't know anything about Simple.OData (this it https://github.com/simplefx/Simple.OData) - I trust the guys who wrote it a lot, but I don't know how well their dynamic code works on WP and MonoDroid. I believe it should work on both - but there may be issues with any code that relies on Reflection.Emit.

最后一点-每当您进行与WP相关的任何网络时,请尽可能尝试启用GZip压缩-WP默认情况下不提供此功能.

One final point - whenever you do anything network related on WP, always try to enable GZip compression if you can - WP doesn't provide this by default.

这篇关于连接MVVMCross Portable连接到WCF DataService.是否有可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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