简体   繁体   English

WPF:我可以有一个专门用于处理Web服务的项目吗?

[英]WPF: Can I have one project dedicated to handling web services?

I have a wpf application with multiple projects. 我有多个项目的WPF应用程序。 I'm wondering if it's best to have one project that handles all the web services and have each project reference this one project. 我想知道是否最好有一个处理所有Web服务的项目,并让每个项目都引用这个项目。 Is this even possible, or does each project need to handle its own web services? 这是否有可能,还是每个项目都需要处理自己的Web服务?

This is possible and would be a great way to seperate your web services to be used by other parts of your system. 这是可能的,并且是分离Web服务以供系统其他部分使用的好方法。

If you create one project that has WCF, ASMX or any other type of service you can add a web service reference to your other projects or hook it all up manually! 如果您创建一个具有WCF,ASMX或任何其他类型的服务的项目,则可以将Web服务引用添加到其他项目或手动将其全部连接! The individual projects can pass in configuration properties (URLs, or any other pieces of data) or defaults could be set in the web service project itself! 各个项目可以传入配置属性(URL或任何其他数据),或者可以在Web服务项目本身中设置默认值!

You can absolutely do that! 您绝对可以做到! In fact, I'd say it's preferred - that way your single web service project can be re-used by different clients, whether it be WPF, Silverlight, or ASP.NET MVC (using AJAX). 实际上,我想说这是首选-这样,您的单个Web服务项目就可以被不同的客户端重复使用,无论它是WPF,Silverlight还是ASP.NET MVC(使用AJAX)。 For example: 例如:

  1. WebServiceProject Web服务专案
  2. WpfProject Wpf专案
  3. SilverlightProject Silverlight项目

Projects 2 and 3 would have a Service Reference back to project 1, thus eliminating the need to possibly duplicate data access code. 项目2和3可以将服务引用返回到项目1,从而消除了可能重复数据访问代码的需求。

Here is the MSDN reference page for adding Web References in Visual Studio. 这是用于在Visual Studio中添加Web参考的MSDN参考页面

Hope this helps! 希望这可以帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在一个asp.net项目中的两个不同的Web配置中有两个连接字符串 - can i have two connection string in two different web config in one asp.net project 如何使用一种类方法使用2种Web服务? - How can I consume 2 web services with one class method? 如何在一个HttpServiceHost上托管两个或多个Web服务? - How can I host two or more web services on one HttpServiceHost? 处理未经身份验证的Web服务 - Handling unauthenticated web services 我可以在WPF中使用一个具有多个TargetType的样式吗? - Can I have one Style with multiple TargetType in WPF? 如何将一个项目转换为另一个项目(“无法将类型‘Project.Services...’隐式转换为‘Project.MVC...’) - How can I Cast one Project to another ("Cannot implicitly convert type 'Project.Services...' to 'Project.MVC...') 我们可以将项目类型用作Windows服务的控制台应用程序吗? - can we have project type as console application for Windows services? 当我将 WPF UserControl 与内置项目以外的项目一起使用时,我的 WPF UserControl 无法找到资源 - My WPF UserControl can't locate resources when I use it with a project other than the one it was built in 如何让WPF在调试模式下使用一种窗口样式而在发布模式下使用另一种窗口样式? - How can I have WPF use one window style for Debug mode and another for Release mode? 我可以将文件从一个项目文件夹发送到C#Web中的另一个项目文件夹吗 - Can I send file from one project folder to an other project folder in C# web
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM