Click here to Skip to main content
14,603,017 members

Developing a GTK# Application that Retrieves Detailed Stock Information using MonoDevelop and Web Services

Rate this:
4.00 (1 vote)
Please Sign up or sign in to vote.
4.00 (1 vote)
18 Oct 2008CPOL
Web Services consumption using MonoDevelop and GTK#


This article introduces GTK# development with MonoDevelop for consuming simple web services. The web service we are going to use is the Stock Ticker service available at


This project is developed using MonoDevelop and GTK# 2.0. I have developed and tested this application in KDE 3.5 and GNOME with OpenSUSE 11.

Creating a Web Reference

First, we need to create a Web Reference to the Stock ticker service in the form of a DLL file so that we can consume it. Here are the steps for the same.

  1. Convert the WSDL of the Web Service in C# Code using wsdl tool.
  2. Generate a Library file using the generated .cs file.

Open your terminal and type the following commands:

$ wsdl
$ mcs /target:library StockQuote.cs    -r System.Web.Services

A DLL file with the name StockQuote.dll will be created. Though we can do this using the MonoDevelop IDE, I prefer this technique because we could store all web references in one special folder and reference them as required in projects.

Create a new Solution in MonoDevelop. Add a project of the type GTK# 2.0.


Then, the project will create a GTK# form with the name MainWindow.cs. You can open this in Designer mode which shows up a WYSIWYG editor. One major feature of GTK# for design is that it asks you to first define a Container before you get to add any Widgets.

I have used a table as my container to design the form as shown below:


The StockQuote web service returns the result in an XML format. So we need to extract information from it. You can see the format here. Just lookup a company, say MSFT and see the format of result. Therefore, we need to add two References, one is for System.Xml and the other is for the StockQuote.dll we generated earlier.

References can be added easily by Right clicking the References folder in Solution window and selecting Edit References... This will open a dialog box as shown below:


Next, we add the reference to StockQuote.dll by selecting the .NET Assembly Tab.


In GTK#, a Widget is associated with Signals. Signals associated with a widget can be seen in the Properties window when we select in the designer. We can double click on the Signal to generate event handler. Next, we add signal handler to the Button "Get latest stock information" and write the following code:

protected virtual void OnButton1Clicked (object sender, System.EventArgs e)
    String quoteSymbol="MSFT";
    StockQuote quote = new StockQuote();
    string toParse=(quote.GetQuote(quoteSymbol)); 
    XmlDocument doc=new XmlDocument();

We can then build the project by pressing F8. The project can be run by pressing the F5 key.

Points of Interest

The code for the designer refused to show up the IDs of the widgets that I dragged and dropped. I got toppled in the first place. It actually shows the widget IDs when you compile the project after dropping the widgets.


  • v0.1b Retrieving detailed stock information of a given stock symbol


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Shyam Bharath
Software Developer Droid Labs
India India
Shyam Bharath just finished his bachelor of technology in Computer science and Engineering from Vellore Institute of Technology. He is passionate about application development. He loves coding in C#, Python and more recently Mono.

Right now he is working in J2EE technologies in a private firm in India. In his spare time, he reads spiritual books.

Exam-O-Matic - Online exam conduction tool in ASP.NET

Comments and Discussions

-- There are no messages in this forum --
Posted 18 Oct 2008

Tagged as


6 bookmarked