Exforsys.com
 

Sponsored Links

 

ASP.NET Tutorials

 
Home Tutorials ASP.NET
 

Creating and consuming XML Web Services with C#

 

Creating and consuming XML Web Services with C# - Page 2

Page 2 of 2


Making the Web Service Client


Let's make a Console application which consumes this service. You can use any language and platform to consume this service, that's the purpose of XML WebService. Now, this procedure requires some mouse clicking :). So I will write down the steps instead of pasting the screen shots.


  1. Start a new project which will be a Console Application in Visual C#.NET.
  2. Once you see the code view in the Console application, right click on the project name from the Solution Explorer. Remember that project name will be written in bold.
  3. Click on "Add Web Reference".
  4. Paste the URL of your WebService. You can get the URL of your WebService when you view your webservice in IE or any other browser.
  5. Click GO.
  6. Your webservice will be loaded. In the Web Reference Name textbox, write "MyService" and click Add Reference.
  7. You will see that the web reference has been added in your Solution Explorer, meaning that webservice is ready to kick some butt.

Now, all you have to do is to make the instance of the WebService class using the reference name that you provided, which is "MyService".


using System;

namespace MyClient
{
class Class1
{

[STAThread]
static void Main(string[] args)
{
// Make an instance of the WebService Class
// using the Web Reference you provided
MyService.Service1 service = new MyService.Service1();
// Assign message what ever is returned
// from HelloWorld in this case "HelloWorld"
string message = service.HelloWorld();
// Prints out the message on the screen
Console.WriteLine(message);

}
}
}


And that's it. You use the webservice class just like any other class. Something you need to keep in mind is that if you decide to make a new method in your webservice and want to make it available to the client, then always remember to build your webservice solution so that the assembly can be updated. If you don't build your webservice, you won't be able to see the methods on the client side.



Http Clients Creating .NET Consumers

A consumer is the one who uses the service and a provider is the one who provides the service. Http clients can be an asp.net application or any other application that communicates with the web service through internet.


Web Services and Legacy Clients

As I said previously that Web Services are used to communicate between different systems. These systems can be writting different operating systems but their communication medium is xml which they all can understand. These legacy systems can be COBOL, FORTON and PASCAL. So instead of making a complete new application in Asp.net Web Service can be used to link different systems together.




First Page: Creating and consuming XML Web Services with C#


Read Next: ASP .NET Migration and Interoperability



 

 

Comments


debu_2005_abcd said:

  very helpful
May 25, 2005, 10:28 am

mythili said:

  worked like a jump starter. ver very helful
March 7, 2007, 3:27 pm

Prachi 123456 said:

  Good to start with!
December 9, 2007, 10:55 pm

philip12345 said:

  Very Very good introduction to webservices. I have read a lot of complex articles that make it too boring to learn about webservices, They just make the reader irritated . You have given a simple programme to create and consume webservices. Excellent ! simply Excellent!!
April 3, 2008, 11:45 am

Manoj12345 said:

  This article is a very good starter. I was searching the Web for a good article on Web Services because i could not understand what they are speaking? After reading this article I have a got a very good idea about WebService. Thanks to Exforsys and author of this article for explaining WebServices in a simple and sweet manner.
Excellent article!!!
May 13, 2008, 9:03 pm

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape