调用 Web 服务时,Prism 可以模块化吗? [英] Can Prism be modular when calling webservices?

查看:54
本文介绍了调用 Web 服务时,Prism 可以模块化吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个演示棱镜应用程序.我的应用程序有一个 shell 项目和另一个具有棱镜服务和视图(和视图模型)的模块.(主要基于 Mike Taulty 的视频,但使用 WPF 而不是 Silverlight).

I am playing around creating a demo prism application. The application I have has a shell project and another module that has a prism service and a view (and a view-model). (mostly based off of Mike Taulty's videos, but in WPF rather than silverlight).

我设置了棱镜服务来调用我的网络服务.似乎所有设置都正确,但是当我调用此代码时:

I setup the prism-service to call my web service. It seemed all setup right, but when I call this code:

 MyServiceReferenceClient myServiceReferenceClient = new MyServiceReferenceClient();

我收到此错误:

在 ServiceModel 客户端配置部分中找不到引用合同MyServiceReference.IMyService"的默认端点元素.这可能是因为找不到您的应用程序的配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素.

Could not find default endpoint element that references contract 'MyServiceReference.IMyService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

我在 google 上搜索了错误,发现我需要将 app.config 的内容放入我的 shell 项目中才能使其工作.

I googled the error and found that I needed to put the contents of my app.config into my shell project for it to work.

我将该文件复制到我的 Shell 项目中,效果很好.

I copied that file over to my Shell project and it worked just fine.

但我不喜欢这样.棱镜的想法是模块化.如果我必须引用模块中调用的所有 Web 服务,那么 shell 必须比它应该知道的更多地了解每个模块的内部工作原理.

But I don't like this. The idea of prism is to be modular. If I have to have references to all the web services called in the modules then the shell has to know more about the inner workings of each module than it should.

有没有一种方法可以在模块中调用 Web 服务,并且仍然具有模块(通过配置文件)和区域的酷炫优势,并且区域是 shell 需要知道的唯一事情?

Is there a way to call web services in modules and still have the cool Prism benefits of modules (via config file) and regions being the only thing the shell needs to know about?

推荐答案

这篇文章以与您相同的方式处理您的问题:http://blogs.southworks.net/matiasb/2009/06/20/how-to-consume-wcf-services-from-composite-application-guide-for-wpf-and-silverlightprism-v2-modules/.此外,正如您提到的,它建议在模块内以编程方式配置 WCF,以避免让 Shell 知道它不需要知道的有关模块的信息.

This post delas with your issue in the same way that you did: http://blogs.southworks.net/matiasb/2009/06/20/how-to-consume-wcf-services-from-composite-application-guidance-for-wpf-and-silverlightprism-v2-modules/. Additionally, as you mentioned, it suggests to configure WCF programatically within the module to avoid having the Shell know information it does not need to know about modules.

这篇关于调用 Web 服务时,Prism 可以模块化吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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