alt
Advertisement

Online Training
Career Series
Exforsys
Exforsys arrow Tutorials arrow ASP.NET arrow Creating and consuming XML Web Services with C#
Site Search
Sponsored Links



Creating and consuming XML Web Services with C#
Article Index
Creating and consuming XML Web Services with C#
Page 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.


Trackback(0)
Comments (5)add comment

debu_2005_abcd said:

  very helpful
May 25, 2005

mythili said:

  worked like a jump starter. ver very helful
March 07, 2007

Prachi 123456 said:

  Good to start with!
December 09, 2007

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 03, 2008

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

Write comment

busy

 
< Prev   Next >
Sponsored Links
© 2008 Exforsys.com
Joomla! is Free Software released under the GNU/GPL License.
Page copy protected against web site content infringement by Copyscape