Calling Web Services from a web page
-
Dear people, I have been searching for the correct code to call upon a webservice directly from an aspx page. Can anyone tell me how to do it?
wherever you need to call a web service, it is same. add a web reference to the asmx, which will create a proxy class for you. Then just make calls to methods as if the Web service is local to you. Bhaskara
-
Dear people, I have been searching for the correct code to call upon a webservice directly from an aspx page. Can anyone tell me how to do it?
Let us say you created web service with some web method called foo(). Now you create a web page in a new project from which you want to call this web service. The first thing you need to do is to add a web reference to the Reference node of your project. This opens up a wizard where you need to reference your .asmx or .wdl url reference. Once you do this, you have the localhost( your local website)with the web service ready. Add a button to your page. In the click event you need to create the following code. Before you write this code, at the top of the page, you need to add: imports localhost.service1 in the click event add the following code: dim mysvc as new service1 document.write(mysvc.foo()) ps;The service1 is having the method foo() when you created the web service. I will try to write a codewalk on this next time to the CodeProject. :)