从WSDL文件创建ASMX web服务

时间:2022-12-03 22:55:51

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

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

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.

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

I've gone as far as using:

我甚至用过:

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

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.

现在我有了一个.vb文件,它是由该WSDL生成的。但是我不确定我应该怎么处理这个VB文件。看起来它有一个公共接口,但是没有实现接口的类。它还为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.

我希望有某种存根,我在其中输入代码来完成服务调用。我以前只创建过简单的web服务,它们都没有使用公共接口,所以我不熟悉这里的情况。

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.

此时,我不确定如何使用生成的.vb文件,并使其与一个.asmx文件一起工作,以及完成该接口所需的额外代码。

2 个解决方案

#1


33  

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

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

If you got inteface (with some more attributes that were automatically generated:

如果你有inteface(更多的属性自动生成:


public interface IRealWebService
{
    string GetName();

}

You should make new service:

你应该提供新的服务:


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

    #region IRealWebService Members

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

#2


4  

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.

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

#1


33  

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

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

If you got inteface (with some more attributes that were automatically generated:

如果你有inteface(更多的属性自动生成:


public interface IRealWebService
{
    string GetName();

}

You should make new service:

你应该提供新的服务:


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

    #region IRealWebService Members

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

#2


4  

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.

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