Microsoft Knowledge Base Web Service Consumer

Summary

In this Article I am going to show you how to consume Microsoft knowledge base web service from our client application, this service provided by www.santra.com. This web service exposes three web methods to access over the web. They are KBFullList, KBTitle, KBSearch I got this functions details when I am going through the WSDL files.http://rob.santra.com/webservices/public/mskb/index.asmx?wsdl

Web Service

Web service is simply an application that exposes a Web-accessible API. That means you can invoke this application programmatically over the Web. Using SOAP Protocol XML+HTTP = SOAP (Simple Object Access protocol).

Web services allow applications to share data. Web services can be called across platforms and operating systems regardless of programming language. Web service makes 100% Interoperability. Web Service consists of HTTP, SOAP, WSDL, DISCO and UDDI.

HTTP is the protocol used to send SOAP message between Web Service and client. Today most of the firewall configured to allows http traffic on port 80. And SSL port 443.

SOAP (Simple Object Access Protocol) is message-based protocol. SOAP messages are nothing but XML document. SOAP messages are standard format that includes Envelop, Header and Body. SOAP just sits top of the HTTP protocols.

WSDL (Web Service Description Language) will describe about methods, data type, input, and output parameters of each Web Methods that supported by web service. WSDL based on XML.

DISCO - Discovery to locate the web service.

UDDI - Universal Description Discovery Integration this is also called web based yellow pages for web service. Once business people developed their Web service they can register under UDDI to other people to use and search.

Web Service is nothing but ASP.NET Application. Web service has. .asmx file extension.

Creating a Proxy class for the Web service

First we need to create a Client project as a C# Console Application project. Click Reference and right click you will see pop-up menu with two options Add Reference and Add Web Reference as shown in Figure 1.

MSBKCo1.jpg

Figure 1. Adding Web Reference

In this menu click Add Web Reference options. You will get pop-up dialog window as shown in Figure 2.

MSBKCo2.jpg

Figure 2. Browsing a Web Service URL.

In this dialog an Address filed enter this URL http://rob.santra.com/webservices/public/mskb/index.asmx this will add proxy object to our client project so that we can have reference to this web service. Then click go arrow this will shows the entire web Methods which is supported by this above web Service. As shown in Figure 3.  

MSBKCo3.jpg

Figure 3. MSKB Web Service Methods.

Once you finish this process, we have successfully created a Proxy class for the Web service. Now we are ready to invoke the web methods. 

Client Code to Invoke the Web Service

using System;
using System.Data ;
using System.Data.SqlClient;
using System.Windows.Forms;// This namespace is not required for //webSerivice the reason I added is to use MessageBox to capture the //results
using Ragavan;
namespace SreeniSharp
{
/// <summary>
/// This Implementation of Basic Database Operations in C#
/// </summary>
class Class1
{
/// <summary>
/// Class Implementations
/// </summary>
[STAThread]
static void Main(string[] args)
{
//creating instance of Webservice.
com.santra.rob.MSKB msWS= new com.santra.rob.MSKB();
//This WebMethod will take Knowledge base ID as input and returns
//corresponding Title of the article for that KB ID.
string sTitle = msWS.KBTitle("Q142959");
//This WebMethod will take Keyword as a string to look for KB database
// and returns the result
string sSearchResult= msWS.KBSearch("XML");
//This WebMethod will take Knowledge base ID as input and returns
//corresponding article for the KB ID.
string sFullListString = msWS.KBFullList("Q142959");
MessageBox.Show(sFullListString,"Ragavan WebService Result");
Console.Read();
}
}
}

Output of Web Methods

KBTitle [WebMethod output] 
This WebMethod will return string as Article Title  

MSBKCo4.jpg

KBSearch [WebMethod output] 
This WebMethod will return Search result based on search string as XML Data Island. 

MSBKCo5.jpg

KBFullList [WebMethod output]
This web Method will returns full article content based on Article ID.

MSBKCo6.jpg

Up Next
    Ebook Download
    View all
    Learn
    View all