简体   繁体   English

您可以从Windows窗体应用程序公开XML Web服务吗?

[英]Can you expose XML webservices from a Windows Forms Application?

This might sound like a silly question, but when I search for webservices, I get no information about how to create them in a windows forms application. 这可能听起来像一个愚蠢的问题,但当我搜索webservices时,我得不到有关如何在Windows窗体应用程序中创建它们的信息。

The only result is how to create and expose them by creating an .aspx page. 唯一的结果是如何通过创建.aspx页面来创建和公开它们。

So my questions is: Can you create and expose webservices within a windows forms application or are they somehow tied in with .asp pages? 所以我的问题是:您可以在Windows窗体应用程序中创建和公开Web服务,还是以某种方式与.asp页面绑定?

Thanks! 谢谢!

later edit: Is there an example of how to create a webservice in a .cs file and not in a .aspx file? 稍后编辑:是否有一个如何在.cs文件而不是.aspx文件中创建Web服务的示例?

I would like to say that a WebService is a service interface into your application, not the application itself. 我想说WebService是应用程序的服务接口,而不是应用程序本身。

For exposing a WebService in another hosting enviornment than IIS (where your ASP.Net pages are hosted) you can use the following; 为了在IIS(托管ASP.Net页面)的其他托管环境中公开WebService,您可以使用以下内容:

If you are using the WCF toolkit from Microsoft, this means; 如果您使用的是Microsoft的WCF工具包,这意味着; Create a 'ServiceHost' (actual class name) that can host your webservice implementation. 创建一个可以托管Web服务实现的“ServiceHost”(实际类名)。 This can be done in any application (ASP.Net pages, Winform, NT Service and even a console application). 这可以在任何应用程序中完成(ASP.Net页面,Winform,NT服务甚至控制台应用程序)。

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

First, It is not a silly question at all. 首先,这根本不是一个愚蠢的问题。

are they somehow tied in with .asp pages? 他们是否以某种方式与.asp页面捆绑在一起?

Webservices are not tied to any other application. Web服务不依赖于任何其他应用程序。 A WebService is an could be an Application itself. 一个Web服务 是一种 could是应用程序本身。 You can create a WebService as a part of a solution, which may have any other type of application like Asp.Net WebApplication or no other application at all. 您可以将WebService创建为解决方案的一部分,该解决方案可能包含任何其他类型的应用程序,如Asp.Net WebApplication或根本没有其他应用程序。

You can consume a Webservice form any of the following but not limited to 您可以使用以下任何Web服务表单,但不限于此

  • Console Application 控制台应用
  • Asp.Net Web Application Asp.Net Web应用程序
  • Windows Forms Application Windows窗体应用程序

This article might help 本文可能有所帮助

Traditionally with .net Web Services were implemented using asp.net asmx files hosted in iis. 传统上使用.net Web服务是使用iis中托管的asp.net asmx文件实现的。 With .net 3 came WCF which allows a range of different types of services (not just web services) hosted in a range of .net applications and services, not just iis. 随着.net 3出现了WCF,它允许在一系列.net应用程序和服务中托管一系列不同类型的服务(不仅仅是Web服务),而不仅仅是iis。 WCF is a complex and powerful set of technologies i have found this book to be helpful WCF是一套复杂而强大的技术,我发现本书很有帮助

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

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