创建从WSDL文件的ASMX Web服务 [英] Create an ASMX web service from a WSDL file

查看:688
本文介绍了创建从WSDL文件的ASMX Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WSDL文件,我试图创建一个符合WSDL Web服务。

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.exe用mywsdl.wsdl / L:VB / serverInterface

现在我已经得到了从WSDL生成的.vb文件。但是我不知道我应该用这个VB文件做。它看起来像它有一个公共接口在那里,但没有类实现接口。它还具有WSDL中的类型一堆局部类的。

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.

我原以为那里有某种存根的,我把在code完成服务调用。我只之前创建简单的Web服务,其中没有使用公共接口,所以我不熟悉的东西是怎么回事。

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.

在这一点上我不知道我是如何使用生成的.vb文件,并使其与一个.asmx文件和哪些额外的编码工作是需要完成的接口。

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服务,并添加产生,所以它继承该接口的接口。 Visual Studio中可以自动生成接口的每一个方法存根。用WebMethod属性标记它们,并把一些code,它会返回一些测试数据/结果。

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.

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

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


public interface IRealWebService
{
    string GetName();

}

您应该做出新的服务:


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

    #region IRealWebService Members

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

这篇关于创建从WSDL文件的ASMX Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆