Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to generate web service out of wsdl

Tags:

c#

wsdl

asmx

Client provided me the wsdl to generate the web service.But when I used the wsdl.exe command it generated the .cs class out of it. I consumed that class in my web service and when I provided the wsdl to client it didn't match their schema. Actually I want the .asmx to be automatically generated from the wsdl so that I could fill in the web method. So that it will exactly match their schema. Hope it make sense.

like image 404
alice7 Avatar asked Sep 08 '09 16:09

alice7


People also ask

How is a WSDL file generated?

A Web Services Description Language (WSDL) document specifies the interface to a web service, and enables a web service client to start it. A WSDL document that is generated from a message model defines web service requests and responses in terms of the messages that you have defined in that message model.

How do I find the WSDL URL for a web service?

You can retrieve the outer-most WSDL file (defined by the <wsdl-file> element within the webservices. xml file) by appending the string /wsdl or /wsdl/ to the endpoint address, for example, http://example.com/services/stockquote/wsdl .


1 Answers

There isn't a magic bullet solution for what you're looking for, unfortunately. Here's what you can do:

  • create an Interface class using this command in the Visual Studio Command Prompt window:

    wsdl.exe yourFile.wsdl /l:CS /serverInterface
    Use VB or CS for your language of choice. This will create a new .cs or .vb file.

  • Create a new .NET Web Service project. Import Existing File into your project - the file that was created in the step above.

  • In your .asmx.cs file in Code-View, modify your class as such:

 

 public class MyWebService : System.Web.Services.WebService, IMyWsdlInterface  {          [WebMethod]      public string GetSomeString()      {          //you'll have to write your own business logic           return "Hello SOAP World";      }  } 
like image 102
p.campbell Avatar answered Sep 19 '22 06:09

p.campbell