[英]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:
例如:
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.