Visual Basic
  Home arrow Visual Basic arrow Page 4 - Developing an XML Web Service Using Visual...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC

Developing an XML Web Service Using Visual Studio 2005
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 55
    2005-12-13

    Table of Contents:
  • Developing an XML Web Service Using Visual Studio 2005
  • Brief explanation of the “Number to Words” XML Web Service
  • Creating XML Web Service using Visual Studio 2005
  • Developing the XML Web Service
  • Developing the XML Web Service continued
  • Executing and testing the XML Web Service

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Developing an XML Web Service Using Visual Studio 2005 - Developing the XML Web Service


    (Page 4 of 6 )

    Before proceeding further, you need to remove (or comment) all the statements related to the “HelloWorld” method (as it is intended only for demonstration). 

    Start with a new method “NumberToWords” as following:

    [WebMethod(Description = "Returns the given number in words.")]
        public string NumberToWords(long Number)
        {
            string sRetVal = "";
            try
            {
                sRetVal = ConvertToWords(Number);
            }
            catch (Exception ex)
            {
                return String.Format("Error: {0}", ex.Message);
            }
            return sRetVal;
        }

    You should observe that the “NumberToWords” method does not process anything at the moment (apart from accepting a “long” number as parameter).  The processing starts with the “ConvertToWords” method.  Now, let us proceed with the “ConvertToWords” method as following:

    private string ConvertToWords(long lValue)
        {
            //If the give number excides 999 trillion then raise an exception.
            if (lValue.ToString().Length > 15)
                throw new Exception("Excides maximum limit. This Service can translate up to 999 trillion.");
            string sInWords = "";
            string sSource = lValue.ToString();
            string sStirngToProcess = "", sProcessedString = "";
            string[] arrPalce = { "", " Thousand ", " Million ", " Billion ", " Trillion " };
            int nCount = 0;
            while (sSource.Trim().Length > 0)
            {
                //Take last 3 digits from the given number
                if (sSource.Length > 3)
                {
                    sStirngToProcess = sSource.Substring(sSource.Length - 3);
                    sSource = sSource.Substring(0, sSource.Length - 3);
                }
                else
                {
                    sStirngToProcess = sSource;
                    sSource = "";
                }
                //Process last 3 digits
                sProcessedString = Process3DigitNumber(sStirngToProcess);
                if (sProcessedString.Trim().Length > 0)
                    sInWords = sProcessedString + arrPalce[nCount] +
    sInWords;
                nCount++;
            }
            if (sInWords.Trim().Length <= 0)
                sInWords = "Zero";
            return sInWords;
        }

    You could observe from the above code that the number gets divided into several chunks which are later processed by the “Process3DigitNumber” method.  Now, let us go through the implementation details of “Process3DigitNumber”, “Process2DigitNumber” and “ProcessSingleDigitNumber” in the next section.

    More Visual Basic Articles
    More By Jagadish Chaterjee


       · I hope this article gave you a good grounding in how to develop an XML web service,...
       · I'm confortable with web service development. However, you should have completed how...
       · Very good explaination up to this point but cut a bit short. Perhaps it will be...
       · well i guess the title says it all, i need to know how to use it now... do i need...
       · Here is the VB Code for those who don't feel like translating C#.Imports...
       · File->Add to project->create or add an existing onein that project add web...
       · I have the same problem that the undersigned has. The only differance is that I have...
     

    VISUAL BASIC ARTICLES

    - Developing an XML Web Service Using Visual S...
    - Creating an HTML File List with VB
    - Fun with Email: VB6, CDO, MAPI, and a Remote...
    - Extranet/Intranet Dictionary Cracker in VB
    - Finding Default App Icons With Visual Basic
    - Registry Fever With Visual Basic
    - Implementing An ADO Data Control With VB6
    - Printing With Visual Basic
    - MSMQ Part 1/2: Architecture and Simple Imple...
    - Magnifying The Desktop With Visual Basic
    - Sending Email With MAPI Components in Visual...
    - Two Person Chat With The Winsock Control And...
    - A Real-Time ActiveX News Control
    - Accessing the Windows API in Visual Basic


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway