How to call the Web Service provided by others
Disclaimer: This article does not tell the concept of WebService, purely using methods. Please follow these steps:
1. Open the website: http://www.xmethods.com. This website provides a lot of WebService, we choose one of the relatively simple as an example: This webservice has a method of returning a celebrity quotes, introduced.
2, click the Random Qote link, find his WSDL address:
3, copy the address, open MS.NET, create an ASP.NET project, open the Add Reference dialog, and enter the address into the URL. It can be seen that the WebService provides an interface getQuote (). Click the "Add Reference" button to return to the main interface. 4, add the following code in the code hidden file:
Private Void Page_Load (Object Sender, System.EventArgs E)
{
/ / Place the user code here to initialize the page
com.boyzoid.www.randomquoteService RQS = New Teatest.com.boyzoid.www.randomquoteService ();
This.Response.write (RQS.GetQuote ());
}
5, the operation results are as follows (because each running result may be different, the following is the result of refreshing several times): "a nickel ain't Worth A Dime Anymore." Yogi Berra
"Kids, you tried your best and you failed miserably. The Lesson IS, Never Try." Homer Simpson
"Always Do Sober What You Said You'd Do Drunk. That Will Teach You to Keep Your Mouth Shut." Ernest Hemingway