Creating a .NET client to test with LEIF/Hydra

Article ID: 1210
Last updated: 15 Sep, 2009
Article ID: 1210
Last updated: 15 Sep, 2009
Revision: 1
Views: 1934
Posted: 01 Jan, 2000
by --
Updated: 15 Sep, 2009
by

Problem



When working with web services in LEIF or Hydra, one of the goals is interoperability with other platforms and vendors.  A common user of web services are developers who use .NET clients to access web services implemented using LEIF or Hydra.  In order to ensure that these clients will work correctly with these services, a developer will need to be able to create sample .NET clients to test the services.


Action


A sample .NET client can be easily created using the following steps with any of the Visual Studio .NET platforms.  For this example, I will create a client for the HelloWorld example.

  1. Open a command prompt with the chosen .NET platform environment configured and navigate to the HelloWorld example directory.
  2. Generate a sample proxy from your wsdl with the following command:
    • wsdl HelloWorld.wsdl
  3. The generated proxy will, by default, use the address of the service defined in the wsdl.  If you need to contact localhost for testing you might have to edit the url in the class constructor.  Note:  The name of the file generated is taken from the service name defined in the wsdl. i.e., <service name="GreetingService">
  4. Compile the proxy into a dll with the following command. 
    • csc /t:library GreetingService.cs
  5. Create a HelloWorldClient.cs file with the following contents:

using System;

public class HelloWorldClient //this must match the filename.
{
  public static void Main()
  {
// Use the name of the service for the object here.
    GreetingService objService =
new GreetingService();
    //Output the return value to the console.
    Console.WriteLine(objService.sayHello("World"));
  }
}

  6.  Compile the client using the proxy dll we already compiled:

    • csc HelloWorldClient.cs /r:GreetingService.dll

You now have a fully functioning HelloWorldClient.exe.  Once you have the GreetingService implemented and deployed as described in the HelloWorld example, you can execute the HelloWorldClient to contact the service.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 1210
Last updated: 15 Sep, 2009
Revision: 1
Views: 1934
Posted: 01 Jan, 2000 by --
Updated: 15 Sep, 2009 by
Also listed in


Others in this category