Skip to main content

Web Service Implementation

The implementation of our Web Service will consist of three classes, within a package called “CInfo”:

  1. A persistent (database) class, CInfo.Company. This class represents information about a particular company and manages storing this information within the database.

  2. A serial (embedded) class, CInfo.Address. This class implements a complex datatype representing an address. We will use this as a property within our CInfo.Company class.

  3. A Web Service class, CInfo.WebService. This class implements the actual Web Service.

Note that in this example, we will use the persistent objects (CInfo.Company) stored within our database as the basis for the information we return via our Web Method. In an actual Web Service, you could also take this approach, or you could define a set of more specialized, transient (i.e., non-persistent) classes and use them to represent the data used within your Web Methods. For example, in a real database, a persistent class containing company information may have more properties than you wish to use within your Web Service. In this case, you could define a smaller, transient class containing only the fields you need and copy the appropriate values into them from the larger persistent object.

FeedbackOpens in a new tab