none
.wsdl file- How to?

    Question

  • I am new to Web Services. I have gone through various articles & got the idea of web services.

    I have learnt how to add web reference from a web service link (.asmx)

    In our .Net application, our client has provided a .wsdl file not an .asmx file.


    How to use this .wsdl file of a web service and access methods & data through it? Also, the web service seems to be private (which requires login)

    Thanks,

    David.


    DAVID



    • Edited by David_7 Tuesday, July 23, 2013 3:11 PM
    Tuesday, July 23, 2013 3:02 PM

Answers

  • Right click on the project in Visual Studio, select Add Service Reference, paste the path to your wsdl file (e.g. c:\file.wsdl) and click on the Go button. You will then be able to use the generated client proxy to access the service in code:

    var proxy = new YourServiceReferenceNamespace.YourServiceClient();
    proxy.DoSomething();
    

    • Marked as answer by David_7 Thursday, July 25, 2013 8:47 AM
    Tuesday, July 23, 2013 6:48 PM

All replies

  • Right click on the project in Visual Studio, select Add Service Reference, paste the path to your wsdl file (e.g. c:\file.wsdl) and click on the Go button. You will then be able to use the generated client proxy to access the service in code:

    var proxy = new YourServiceReferenceNamespace.YourServiceClient();
    proxy.DoSomething();
    

    • Marked as answer by David_7 Thursday, July 25, 2013 8:47 AM
    Tuesday, July 23, 2013 6:48 PM
  • You can also use the svcutil.exe tool to generate manually the code that Visual Studio will generate when you add the Service Reference, as Magnus has replied.

    Juan Casanova http://jawsofdotnet.blogspot.com - My .Net babling blog

    Wednesday, July 24, 2013 6:21 AM
  • You can create web service proxy from the wsdl file using wsdl.exe

    take a look at below links

    http://stackoverflow.com/questions/4304281/create-web-service-proxy-in-visual-studio-from-a-wsdl-file

    http://forums.asp.net/t/1313373.aspx/1



    Mark ANSWER if this reply resolves your query, If helpful then VOTE HELPFUL
    Everything about SQL Server | Experience inside SQL Server -Mohammad Nizamuddin

    Wednesday, July 24, 2013 6:30 AM
  • Hi Magnus, Thanks for the reply. 

    I guess this will work in Visual Studio 2008 / 2010.

    This project is developed using Visual Studio 2005 and .Net Framework 2.0, C#

    Can you suggest any solution for VS 2005 project?

    Reg. the solution given above, for example I have to retrieve some data from a method which is in proxy.

    How can I do?

    Thanks.



    DAVID

    Wednesday, July 24, 2013 1:25 PM
  • Hi Juan, Thanks. 

    If I have the wsdl file in C drive

    then should I type the folliowing in Command prompt to generate proxy class 

    svcutil C:\a.wsdl  /language:C# ?

    Please confirm.


    DAVID

    Wednesday, July 24, 2013 1:41 PM
  • Yes it should work. Just bear in mind that you should open a VS command prompt in order to get the svcutil without needing to change path.

    It will also generate mulitple files (at least one with the code and other with the config file that you should include in your application configuration).

    There are other triggers you can use to customice the generated code. A common one is /messageContract, but its really up to you and your tastes which ones use. Just try a few different ones before sticking to a set of parameters.


    Juan Casanova http://jawsofdotnet.blogspot.com - My .Net babling blog

    Wednesday, July 24, 2013 1:47 PM
  • Hi Nizamuddin,

    Thanks for the reply.

    "http://stackoverflow.com/questions/4304281/create-web-service-proxy-in-visual-studio-from-a-wsdl-file" -

    Using the suggestion in the link, got the below error: - i.e. wsdl.exe C:\a.wsdl / serverInterface

    the error message is displayed 

    "Unable to cast object of type 'System.Xml.XmlElement' to type 'System.web.Services.Description.ServiceDescriptionFormatExtension'.


    DAVID

    Wednesday, July 24, 2013 2:34 PM