Easy and Clear sample of how to use a web service  
Author Message
omar_rapid





PostPosted: Visual C# General, Easy and Clear sample of how to use a web service Top

Hi Y'all

Does anybody have a simple code on accessing a web service, there are a lot of web service at xmethods.net but my problem is I have a hard time accessing it coz I don't know how. I was able to add a web reference in my application but im having a hard time coding the actual operation.

What should I do Is it similar to the code below

WebService oTheWebService = new Namespace_of_webservice()
String cTheString = oTheWebService.Access_here_the_webservicemethod().ToString();
textBox1.Text = cTheString; // to display if ever the return value.

It would be appreciated if anybody could provide an actual 5 minute guide/sample of web service access.

Y'all be cool!







Visual C#12  
 
 
omar_rapid





PostPosted: Visual C# General, Easy and Clear sample of how to use a web service Top

Hi Y'all

Found out how to add/call a web service, I tried using the bible service, a weather would have been fine, just that wasnt able to find one. I placed a how to in case anybody else needs it. This is based on an actual working example.

How to: (less than five minutes guide to web services)
1. go to www.xmethods.net
2. look for the bible xml web services
3. the wsdl is : http://bible.sumerano.com/bible.asmx WSDL
4. if you are using c# express, create a new project
5. in the solution explorer, right click reference, click add web reference
6. in your application initialize an object using the web service (see code below)
7. voila!

here is the sample code:

private void button1_Click(object sender, EventArgs e)
{
com.sumerano.bible.Bible oBible = new com.sumerano.bible.Bible();
int x;
for (x = 0; x <= 5; x++)
{
MessageBox.Show(oBible.GetVerses(1,1,1)[x].VerseText.ToString());
}
}