Web Service .net 2.0,部署和使用

发布于 2024-08-17 16:15:12 字数 270 浏览 1 评论 0原文

我使用 VS 2005 创建了一个单独的 Web 服务项目。

  1. 我的第一个问题是我可以添加多个服务 (asmx) 文件吗 并在单个 Web 服务项目中使用它们?
  2. 我如何发布它们并从不同的网站使用/调用/消费它们? (我知道当它们在同一个项目但不同时如何使用它们 项目有点令人困惑)
  3. 我如何保护它们以使经过身份验证的用户/应用程序可以使用它们?

使用 VS 2005、.net 2.0、VB.NET(并且我无法使用 WCF)

I created a separate web service project using VS 2005.

  1. My first question is can I add more than 1 service (asmx) files
    and use them in single webservice project?
  2. How can I publish them and use/call/consume them from different websites?
    (I know how to use them when they are in same project but different
    project is bit confusing)
  3. How can I secure them to make them available by authenticated users/apps?

Using VS 2005, .net 2.0, VB.NET (and I cannot use WCF)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冧九 2024-08-24 16:15:12
  1. 是的,这是完全可能的。只要它们进入同一个 Web 服务项目在逻辑上有意义,那就没问题。
  2. 只需像发布普通网站一样发布它们即可。从 VS.NET 内进行 XCOPY 部署或发布。您可以通过在要使用 Web 服务的项目中“添加 Web 引用”来创建客户端代理,然后通过 HTTP 浏览到/选择本地 .asmx 端点。在底层,它会为您生成一个具有相关数据类型的 SOAP 客户端代理类(通过调用 wsdl.exe)。
  3. 要保护这些内容,请查看此处的 MSDN 文档。
  1. Yes, that's perfectly possible. As long as it logically makes sense for them to go in the same web service project, that will be fine.
  2. Just publish them as you would a normal website. XCOPY deployment or Publish from within VS.NET. You create client proxies by 'Adding web reference' in your project that you want to consume the web service and then browse to/select the local .asmx endpoint over HTTP. Under the hood it will generate a SOAP client proxy class for you with the relevant datatypes (by calling wsdl.exe).
  3. For securing these, check out the MSDN docs here.
乖乖兔^ω^ 2024-08-24 16:15:12

我的第一个问题是我可以添加超过 1 个服务 (asmx) 文件吗?
在单个 Web 服务项目中使用它们吗?

您可以向 Web 服务添加多个入口点,以便调用不同的 URL 将调用不同的行为。 添加 In 来实现此目的

[WebMethod]

您可以通过在 Service.cs 文件中的公共方法前面

我如何发布它们并从不同的网站使用/调用/消费它们? (我知道当它们在同一个项目中时如何使用它们,但不同的项目有点混乱)

您可以生成代码以基于 WSDL 文件与 Web 服务交互。我不确定在 .NET 中如何执行此操作,但在 Java 中,有一个命令行工具可以生成类以与其他应用程序中的 SOAP 服务进行交互。毕竟,这就是 Web 服务的全部意义。

如何保护它们的安全,以便经过身份验证的用户/应用程序可以使用它们?

您可能希望在 IIS 方面对此进行管理。虽然可能可以对您的 Web 服务进行一些基本身份验证,但检查用户名,但在访问 Web 服务之前处理此问题可能会更有效。

您还可以使用 Web.config 文件的身份验证属性配置基本身份验证。

My first question is can I add more than 1 service (asmx) files and
use them in single webservice project?

You can add multiple entry points to your webservice, such that calling different URLs will call different behaviors. You can do this by adding

[WebMethod]

In front of public methods inside your Service.cs file.

How can I publish them and use/call/consume them from different websites? (I know how to use them when they are in same project but different project is bit confusing)

You can generate code to interact with the webservice based on the WSDL file. I am not sure how you do this in .NET, but in Java there is a command line tool to generate class to interact with the SOAP service from another applications. This is, after all the entire point of web services.

How can I secure them to make them available by authenticated users/apps?

You probably want to manage this on the IIS side of things. While it is probably possible to some basic authentication to your web service but checking the username, it may be more efficient to handle this before you reach your web service.

You can also configure basic authentication using the Web.config file's authentication attribute.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文