English 中文(简体)
未配置(但有效)的端点会产生什么后果?
原标题:What are the ramifications of an unconfigured (but working) endpoint?

我有一个功能齐全的wcf服务,可以在客户端上使用jQuery执行CRUD操作。我希望这个小型服务应用程序是可移植的,所以我尽量避免任何应用程序或web.config设置(例如特定地址端点)。我已经将我的服务应用程序编译成一个小的dll文件,并在不同网址的几个不同项目中进行了尝试。一切都很好。

我在web.config文件中放入的唯一设置是aspNetCompatibilityEnabled,因为我使用的是表单身份验证。我没有为我的服务约定定义名称或命名空间,而且我的app.config文件是空的,没有连接字符串。当我在.svc文件中键入地址时,我会得到未找到端点的错误。但是,当我使用我在操作合同中定义的UriTemplates时,我的服务是完全可用的。这会产生什么后果?

我不在乎在.svc文件上公开我的数据对象或方法。我只需要这个服务是可移植的,而不是因为一些不可预见的错误而崩溃。

谨慎乐观。

UPDATE After further investigation it appears my example above is the default behavior for WCF. There is a good article from MS that explains it here.

最佳回答

我不知道你说的便携是什么意思。你的服务在dll中,可以在任何web应用程序中使用。然后它取决于您的.NET Framework版本。

在.NET 3.5中,您必须在.svc文件中承载服务,并在配置文件或代码中配置它(服务、端点、行为、AspNetCompatibility)。

在.NET 4.0中,您可以利用简化的配置模型,该模型可以根据提供的其他信息为您创建端点。您可以通过基于配置的激活或通过服务路由在.svc文件中承载服务。在所有情况下,使用WebServiceHostFactory允许使用WebHttpBinding自动创建端点是很重要的。您只需要配置AspNetCompatibility。如果您需要进一步指定webHttp行为,您也可以将其放置在配置中,而无需指定行为的名称。这样的行为将被视为所有服务的默认行为(在.NET 3.5中也是不可能的)。

在这两种情况下,您都不需要配置基地址,因为它总是从托管web应用程序中获取的。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签