Simplest way of invoking a webservice via SOAP on ASP.NET

34,496

Solution 1

See here: http://msdn.microsoft.com/en-us/library/d9w023sx.aspx

Its very easy in visual studio - you simply add the web reference url and it generates the proxy stub for you.

Solution 2

The simplest thing to do is to just use "Add Service Reference" and point to the WSDL. It will generate the proxy classes for you, including a proxy method which should match the method signature you've been given.

See if you find How to Consume a Web Service to be helpful.

Share:
34,496
Maya Tzadik
Author by

Maya Tzadik

Updated on May 06, 2020

Comments

  • Maya Tzadik
    Maya Tzadik almost 4 years

    I have a webservice on a remote host that I need to invoke from ASP.NET/C# class. What is the simplest way of calling a method via SOAP, given WSDL url and a method signature?

    Given: WSDL url as string(available only at runtime, i.e. variable) Method signature(constant)

    Need to: Create a soap client and perform method call.

  • John Saunders
    John Saunders almost 15 years
    -1: Don't jump to "Add Web Reference" until he say he's stuck at .NET 2.0 and can't use WCF. Otherwise you may be condemning him to live in the past for no good reason.
  • rifferte
    rifferte almost 15 years
    The question mentioned "simple". That is the simplest way :) Besides - using WCF is extremely similar - you just use "Add Service Reference" as opposed to add "Web Reference". A good overview is here: blog.mstern.at/index.php?/archives/…
  • Maya Tzadik
    Maya Tzadik almost 15 years
    good article - thank you! Though, what if I WSDL's is only available at runtime?
  • John Saunders
    John Saunders almost 15 years
    If two things are just as simple, maybe don't recommend the one with no future, ok?
  • John Saunders
    John Saunders almost 15 years
    If the WSDL is not available when you develop your client, then there's something seriously wrong. Maybe the service owners don't understand web services, something like that. The WSDL needs to be available to you, to develop the client.
  • Maya Tzadik
    Maya Tzadik almost 15 years
    It is available. During runtime user selects specific webservices from the list. Each service implements given method, but outcome of method call differs.
  • paracycle
    paracycle over 14 years
    @Alex N.: I think you are referring to the Url of the Web Service being available only at runtime. In that case, after you have created an instance of your web service proxy, just assign the .Url property of that object to any string you want. You can obtain that string from any location you want (a config or from a web location).