| | english | español | français |
  Home|Resources|BCH Interoperability Services 3.0|Quick Start - Step by Step C# project guide   Printer-friendly version

Quick Start - Step by Step C# project guide

Step 1 - Create new project

Start Microsoft visual studio 2005
In menu click on File - New - Project...


Select Visual C# in Project types pane
Select Console Application in Templates pane
Type your application name. e.g. MyDemoApp
Click OK to create project

Step 2 - Add BCH Web service reference

In Solution Explorer pane expand MyDemoApp project tree
Right click on Reference and select Add Web Reference


Enter the BCH WebService endpoint url http://bchtraining.biodiv.org/service/3.0/service.asmx and click Go to retrieve the Web Service Definition
Click Add Reference

Step 3 - Code & Execution

Double click on Program.cs file in Solution Explorer pane and entre the following code in the text editor.

using System;
using MyDemoApp.org.biodiv.bchtraining; // Imported Web Reference

namespace MyDemoApp
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                // Initialize WebService
                BCHWebService30 oWebService = new BCHWebService30();

                // Call SOAP Method
                oWebService.checkAccount("myemail@mydomain.com""mypassword");

                Console.WriteLine("Email and password are correct.");
            }
            catch(Exception e)
            {
                // Output error message to console
                Console.WriteLine(e.Message);
            }
        }
    }
}

To execute the application, in the menu click on Debug - Start Without Debugging

   
   
Update on 2007-04-17
Rate this page  - 3 people have rated this page  
United Nations Environment Programme United Nations