从 WSDL 文件创建 ASMX Web 服务

发布于 2024-07-14 01:42:40 字数 461 浏览 6 评论 0原文

我有一个 WSDL 文件,并且正在尝试创建一个符合 WSDL 的 Web 服务。

我已经使用 WSDL 文件创建了使用现有服务的客户端,但我从未创建过需要遵循特定 WSDL 的 Web 服务。

我已经使用了:

wsdl.exe mywsdl.wsdl /l:VB /serverInterface

现在我已经得到了从该 WSDL 生成的 .vb 文件。 但是我不确定我应该如何处理这个 VB 文件。 看起来它有一个公共接口,但没有实现该接口的类。 它还为 WSDL 中的类型提供了一堆部分类。

我期望有某种存根,我可以在其中放入代码来完成服务调用。 我之前只创建过简单的 Web 服务,并且没有使用公共接口,所以我不熟悉这里发生的事情。

此时,我不确定如何使用生成的 .vb 文件并使其与 .asmx 文件一起使用,以及需要哪些额外的编码来完成该界面。

I have a WSDL file and I am trying to create a web service that conforms to the WSDL.

I've created clients using WSDL files that consume an existing service, but I've never created a web service that needed to follow a specific WSDL.

I've gone as far as using:

wsdl.exe mywsdl.wsdl /l:VB /serverInterface

Now I've got a .vb file generated from that WSDL. However I am not sure what I'm supposed to do with this VB file. It looks like it's got a public interface in there but no class that implements the interface. It also has a bunch of partial classes for the types in the WSDL.

I was expecting there to be some sort of stub where I put in the code to complete the service calls. I've only created simple web services before and none of them used public interfaces so I'm unfamiliar with what is going on here.

At this point I'm not sure how I use the generated .vb file and make it work with an .asmx file and what additional coding is needed to complete the interface.

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

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

发布评论

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

评论(2

倾`听者〃 2024-07-21 01:42:40

如果您已经创建了接口,则需要实现这些接口。
只需创建一个新的 Web 服务并添加您生成的接口,以便它继承该接口。 Visual Studio 可以自动为接口中的每个方法生成存根。 使用 WebMethod 属性标记它们,并放入一些代码以返回一些测试数据/结果。

如果您有此接口(带有自动生成的更多属性):


public interface IRealWebService
{
    string GetName();

}

您应该创建一个新服务:


public class WebTestService : System.Web.Services.WebService, IRealWebService
{

    #region IRealWebService Members

    [WebMethod]
    public string GetName()
    {
        return "It Works !!!!";
    }
    #endregion
}

If you already created interfaces you need to implement those interfaces.
Just create a new web service and add the interface that you generated so that it inherits from that interface. Visual Studio can automatically generate stubs for every method in interface. Mark them with the WebMethod attribute and put some code in that will return some test data/results.

If you have this interface (with some more attributes that were automatically generated):


public interface IRealWebService
{
    string GetName();

}

You should make a new service:


public class WebTestService : System.Web.Services.WebService, IRealWebService
{

    #region IRealWebService Members

    [WebMethod]
    public string GetName()
    {
        return "It Works !!!!";
    }
    #endregion
}
就此别过 2024-07-21 01:42:40

您所需要做的就是创建一个继承自 WSDL.EXE 生成的接口的类,然后实现该接口中的方法。

All you need to do is create a class that inherits from the interface that WSDL.EXE has generated, and then implement the methods from the interface.

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