Home arrow C# arrow Build a C# Stock Quote WebService Part 1/2

Build a C# Stock Quote WebService Part 1/2

Peter Bromberg of EggheadCafe.com discusses how to build a C# stock ticker using XML Web Services.

Author Info:
By: Peter Bromberg
Rating: 5 stars5 stars5 stars5 stars5 stars / 36
January 06, 2003
  1. · Build a C# Stock Quote WebService Part 1/2
  2. · Building the Ticker
  3. · Building the Ticker (cont'd)
  4. · Conclusion

print this article

Build a C# Stock Quote WebService Part 1/2
(Page 1 of 4 )

Spring is almost here, and it's time to create .NET stuff! So, building on my article of last year, "Build a Custom Stock Quote Component", I decided it would be a fun exercise to "stretch my skills" a bit and build a new one, but this time -- to do it in C# as a full-fledged .NET WebService. And, since Microsoft has been nice enough to give away a WebService Behavior HTC that can be "plugged in" to a DHTML web page to act as a webservice consumer, I thought that would be an elegant finishing touch to show an example of building a consumer Web page for my new StockQuote class.

We'll deal with getting the WebService built and running in this installment, and in Part II, we review how to use the WebService DHTML Behavior in a regular client-side .htm page to consume the WebService. (The downloadable code link at the bottom of this article, however, contains ALL the code, 'cause I know how you hate to wait for people's "multiple part' articles!) In Part II, I'll get into some neat client-side stuff, so visit often.

On a side note, If you're in a quandary about DOT NET and you aren't sure whether to stay with VB6 or go to VB7 or start with C#, my advice is -- after a great deal of agonizing study and thought -- conserve all the extra time you can find, DROP EVERYTHING, and get started with C#.

Forget VBScript (its already a dinosaur) as well as VB6 and even Javascript. Microsoft has over a million lines of C# code in the .NET platform - those guys are eating, breathing, sleeping and everything else in C#. And unlike their brethren at Oracle and Sun, they've submitted it to the ECMA for certification.

In sum, C# is an elegant, simple, and powerful programming language that you're almost certain to see on other platforms while the Java guys who are still too busy bashing the guys in Redmond to see what's comin' at-em on the turnpike at 100 miles an hour will likely be wondering what happened.

In this article, we're going to walk through the Webservice C# code first, and then we'll take a look at the DHTML page and how the WebService Behavior can be used to easily wire up the page to act as a webservice consumer.

While this is a pretty simple class with only one method, "GetQuote" it still demonstrates some important techniques- handling and parsing multiple stock symbols as input parameters, utilizing the WebRequestFactory class, as well as the StreamReader and StringBuilder .NET classes to parse and clean up the response stream and process the return values.

Finally, we'll build a valid XML return document that the WebService returns to the calling client, as well some simple error -handling code.
blog comments powered by Disqus

- Introduction to Objects and Classes in C#, P...
- Visual C#.NET, Part 1: Introduction to Progr...
- C# - An Introduction
- Hotmail Exposed: Access Hotmail using C#
- Razor Sharp C#
- Introduction to Objects and Classes in C#
- Making Your Code CLS Compliant
- Programming with MySQL and .NET Technologies
- Socket Programming in C# - Part II
- Socket Programming in C# - Part I
- Creational Patterns in C#
- Type Conversions
- Creating Custom Delegates and Events in C#
- Inheritance and Polymorphism
- Understanding Properties in C#

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials