Simplest way of invoking a webservice via SOAP on ASP.NET
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.
Maya Tzadik
Updated on May 06, 2020Comments
-
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 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 almost 15 yearsThe 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 almost 15 yearsgood article - thank you! Though, what if I WSDL's is only available at runtime?
-
John Saunders almost 15 yearsIf two things are just as simple, maybe don't recommend the one with no future, ok?
-
John Saunders almost 15 yearsIf 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 almost 15 yearsIt is available. During runtime user selects specific webservices from the list. Each service implements given method, but outcome of method call differs.
-
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).