views:

6190

answers:

4

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.

+2  A: 

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.

John Saunders
+9  A: 

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.

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


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
}
Robert Vuković
Thank you. I think this is it. I understand what is going on now! Maybe I should have did it in C# first. I have to do it in VB.net and I'm not that familiar with VB.net yet. But I understand your example perfectly and am able to do it in C#.
metanaito
A: 

When I executed line below, it generated a cs file:

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

Please let me know step by step so that I may process further

Vibhu Gupta
A: 

Is there a way to automate, populating the wsdl generated interface objects with the XML response data? Because some web service returns a big xml stream, which contains hundreds of fields.

If have the wsdl and the xml stream save in xml file, to create that same web service.

BinaryTank