简体   繁体   English

WCF与ASP.NET应用程序

[英]wcf with asp.NET application

What is the best experience of combining wcf services in an asp.NET application? 在asp.NET应用程序中组合wcf服务的最佳经验是什么?
Should I add wcf services files to the asp.NET project? 我应该将wcf服务文件添加到asp.NET项目吗?
Should I create a separate project for the wcf services and refer somehow to them in the asp.NET application? 我应该为wcf服务创建一个单独的项目,然后在asp.NET应用程序中以某种方式引用它们吗?

I presume you have an ASP.NET application that also hosts a few WCF services that can be accessed from the client. 我假设您有一个ASP.NET应用程序,该应用程序还承载一些可以从客户端访问的WCF服务。 There is nothing wrong with this and it works perfectly well. 这没有任何问题,并且运行良好。

The three things you should consider doing are: 您应该考虑做的三件事是:

  1. separate the interfaces for the WCF services into their own assembly 将WCF服务的接口分离到自己的程序集中
  2. keep the data objects that you use in yet another assembly 保留在另一个程序集中使用的数据对象
  3. separate the implementation of the interfaces into their own assembly 将接口的实现分离到自己的程序集中

This may seem like overkill, and it's not always necessary to do it this way, but i would do at least steps 1 & 2. Keeping the data objects and contracts (interfaces) in their own separate assemblies is important as it helps when sharing (referencing) the data objects from different projects (ie if you have a Silverlight or Windows Forms/WPF client that can consume those assemblies). 这似乎有点过头了,并且不一定总是需要这样做,但是我至少要执行步骤1和2。将数据对象和协定(接口)保持在各自独立的程序集中非常重要,因为这有助于共享(引用)来自不同项目的数据对象(即,如果您有可以使用这些程序集的Silverlight或Windows Forms / WPF客户端)。

Separating out the implementation (step 3) is good, but not the most important thing to do. 分离实现(步骤3)是件好事,但这并不是最重要的事情。 If you do follow this step, you can still publish the WCF endpoints through your ASP.NET application. 如果您确实执行了此步骤,则仍然可以通过ASP.NET应用程序发布WCF端点。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM