Home > Articles > Web Services > XML

Building the XML Web Services Four Function Calculator

  • Print
  • + Share This
In this sample chapter you learn the basics of creating XML Web Services as you work through the development of your first service. While building this simple example, you will lay the ground work for every XML Web Service that you will ever build.

See all Sams Teach Yourself on InformIT Web Development Tutorials.

This chapter is from the book

So far, you have learned the principles and architecture behind XML Web services. In this hour, you are going to develop your first service, a four-function calculator. Through this simple example, you will learn enough to immediately begin building a host of more complicated services with real-world applications.

In this hour, we will discuss the following tasks:

  • Creating XML Web services

  • Adding methods in XML Web services

  • Testing your output

  • Generating the contract file

Designing the Service

The first step in the creation of an XML Web service, or any other program actually, is to decide what it will do and to create a design that will give the service the needed functionality. For this demonstration, we will create a very simple design.

My suggestion for designing an XML Web service is to list all the functions that you plan to expose in this manner:

Public Function Add(ByVal iNum1 as Integer, ByVal iNum2 as Integer) as Double

The preceding function declaration uses standard VB notation to describe input parameters, their variable types, and the return type.


The actual function declarations in an XML Web service are slightly different. This declaration is just to be used for the conceptual design of your service.

We want client applications to be able to use our service to add, subtract, multiply, and divide two integers. We will return a double in each instance. All the function declarations look identical to the one for Add, so I won't repeat them here.

  • + Share This
  • 🔖 Save To Your Account