Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create an ASMX web service from a WSDL file

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.

like image 650
dtc Avatar asked Feb 14 '09 01:02

dtc


People also ask

How do I get Asmx from WSDL?

wsdl is notation to serve the wsdl file for the given asmx file. http://localhost/testws/get/services.wsdl points to a services. wsdl file which is located at the url. In this wsdl file there will need to be an address location the points to the url of the service.

How do I create a web service out of WSDL?

In Visual Studio, create or open an Enterprise Server Application project that contains a WSDL file that describes a COBOL application. In the Solution Explorer, right-click the WSDL file; then select Generate Web Service from the context menu.


2 Answers

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 } 
like image 174
Robert Vuković Avatar answered Sep 22 '22 13:09

Robert Vuković


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.

like image 28
John Saunders Avatar answered Sep 24 '22 13:09

John Saunders