Web service integration using C

From KnowledgeTree Document Management Made Simple

Jump to: navigation, search

You made a wise choice in C# as the unit tests were written in for Mono via C#. Check C:\ktdms\knowledgeTree\ktwebservice\nunit (or wherever you have kt installed). You will find the whole gamut in C#. Joy!

Authentication

Here's an example of a console application that authenticates using KnowledgeTreePortClient.login()

using System;
using System.Text;
using KTlab.KnowledgeTreeServiceReference; //make sure you add this service reference

namespace KTlab
{
    class Program
    {
        static void Main(string[] args)
        {
            string strUserName = "admin";
            string strPassword = "admin";
            string strIP = "127.0.0.1";
            KnowledgeTreePortClient objWebservice = new KnowledgeTreePortClient();
            kt_response objResponse;
            Console.WriteLine("Attempting to connect...");
            objResponse = objWebservice.login(strUserName, strPassword, strIP);
            if (objResponse.status_code != 0)
            {
                Console.WriteLine("Cannot authenticate. Reason: " + objResponse.message);
            }
            else
            {
                //put code here
            }
         
                Console.WriteLine("Logging out...");
                objWebservice.logout(strSession);
                Console.WriteLine("Goodbye.");
            }
            // debug pause
            Console.WriteLine("Press Enter to exit");
            Console.ReadLine();

        }
    }
}
Personal tools