example working directory: ExamplesEx01Emp401kService
Web services are a new phenomenon in the computer industry. The concept of a Web service is based on service-based computing which we discuss in Chapter 2.
Section 2.2.5 provides a business-level discussion about Web services and a corresponding definition. A technical-level definition for Web service requires us to first define a service. The definition of a service as given below is not necessarily precise or all encompassing, but rather a working description of the notion of a service. Figure 3.1 depicts a service.
Service: A service is an active program or a software component in a given environment that provides and manages access to a resource that is essential for the function of other entities in the environment.
It is important to note that the notion of resource is rather broad in this definition. A resource could be a piece of hardware, such as a hard disk, or software, such as a math library. It could also be some data in a database or some information, such as a news item. This definition is somewhat simplistic yet very powerful. It is simplistic because it tries to be as broad as possible and specifies very few characteristics or restrictions on qualifying entities. A service need only be a program or a library function to qualify. The key, however, is in the provision and management of a resource. Provision means that it has to make the resource available to other entities, and management denotes controlling and granting the access rights. You can see that this automatically mandates interaction with other entities in its environment. Thus, a program or a software component that does not interact with other entities will not qualify as a service. An equally important aspect is controlling a resource that is desirable by other entities in the service environment. Any resource that is useful only internally to the program does not make it a service.
Web services constitute a special class of services. The services from this class are highly interoperable.
Web Service: A Web service is a service over a computer network that abides by a specific framework to offer its services. The framework provides the means to describe and discover the service, interact with the service, and potentially integrate the Web service with other Web services to offer higher-level Web services.
Figure 3.2 shows a conceptual view of a Web service. The high level of interoperability in this case is achieved through uniform discovery and description standards provided by the framework. Note that the interoperability here is limited among the services that abide by the same set of standards. Web services inherit several characteristics of component-based architectures. Chief among them are:
They have a well-defined build-time and runtime interface for interaction.
They can be thought of as an independent entity, compared with other components of the architecture. They can be built, deployed, and undeployed without affecting other Web services in the architecture (however, this might affect the functioning of the system).
They are individually addressable in the system. This means that a Web service can be approached and communicated with by other entities in its ecosystem. The addressability of a Web service or a component separates them from other software modules that are merely results of functional decomposition.
However, a Web service is not the same as a component. Several characteristics differentiate the two.
Service description —. A Web service is described using a specific standard taxonomy (nomenclature). The taxonomy attaches specific meaning to the terms used in the service description. Taxonomies are discussed in detail in Chapter 6. The description also consists of a means to describe operations facilitated by the service and the mechanics of those operations.
Service discovery —. The standardized description of a class of Web services can be used to discover a specific service within that class. Taxonomy-based classification helps in filtering out services that do not attach the same meaning to the terms used in the interaction.
Service interoperability —. Standardized description and discovery mechanisms make it easy for clients of a service to reconstruct a service interface in a way it finds most suitable at its end. This interface can then be used during service interaction. Thus, clients written virtually in any language can interact with a Web service.
Service composition —. Web services can be combined together to create higher-level Web services — on the fly. The preciseness of service description within a certain taxonomy can make the task of such modularization easy and any service fitting a specific description can become part of a higher-level Web service.
The Web services paradigm consists of components that are aimed at facilitating all the stages in service creation and use. It primarily consists of three components:
Service creation and deployment platform
Service registry
Service description and classification framework
As discussed earlier, Web services are characterized by the underlying framework that defines the process of description, discovery, and interaction. The current widely-popular framework provides a language-independent technology stack between communicating software entities. Figure 3.3 depicts this stack.
In this section, we focus on the XML-messaging and the Service Description layers of the stack as these layers have the most sophisticated standards. Web services security and Web services management, discussed later, are still being debated and discussed within the Web services community. The topic of this book is the Registration and Discovery functionality provided by UDDI.
The underlying communication mechanism in the Web services paradigm is Simple Object Access Protocol (SOAP). SOAP is an Extensible Markup Language (XML) over Hypertext Transfer Protocol (HTTP)-based protocol for accessing components (for example, services and objects) in a platform-independent manner. Appendix G provides more details about SOAP technology.
The major advantage of this lightweight protocol is that it allows services running in one kind of platform (Java 2 Enterprise Edition [J2EE]) to communicate with services in the same or another kind of platform (.NET). Since HTTP is available on all popular platforms, it provides an already at-hand solution to the problem of how services running on different platforms in a network can communicate with each other. The SOAP specification specifies exactly how to encode an HTTP header and an XML file so that a service on one platform can interact with a service in another. Another major advantage of SOAP is that because it is XML/HTTP-based, it can go through the firewall in the same manner that HTTP requests do. Therefore, SOAP solves two obstacles in the service paradigm — interoperability and firewall traversal.
The Service Description layer of the stack refers to the ability of a service to communicate what a Web service can do, where it resides, and how to invoke it. The Web Services Description Language (WSDL) supports service description capabilities in the Web services paradigm. WSDL is an XML-based grammar used to describe services a business offers; it also provides a way for individuals and other businesses to access those services electronically. A WSDL describes four critical pieces of data:
Interface information that describes all publicly available methods
Data type information for all message requests and message responses
Binding information about the transport protocol to be used (e.g., HTTP, HTTPS, or SMTP)
Address information for locating in the form of a service endpoint URL
Appendix H explains WSDL in further detail. WSDL, like SOAP, is also platformand language-independent and is used primarily to describe SOAP-based Web services. WSDL is derived from SOAP and IBM’s Network Accessible Service Specification Language (NASSL). WSDL replaces both NASSL and SOAP as the means of expressing business services in the UDDI registry.
There are two main types of Web service platforms: Java 2 Enterprise Edition (J2EE) and Microsoft’s .NET. BEA, IBM, and Sun Microsystems are just a few of the large software houses that provide J2EE-based Web service platforms. In addition, there are open source platforms, such as Apache Axis, are available for Java-based Web services. Microsoft has its own platform based on the .NET architecture. These platforms implement and supplement various layers and components of the Web service architecture stack depicted in Figure 3.3.
Axis is an open-source product from Apache Software Foundation — an open-source community responsible for developing several notable products such as Tomcat and Cocoon. Axis can be considered as the SOAP engine that can facilitate both Web service deployment and consumption.
Axis can act as a stand-alone server. Axis is also pluggable with Tomcat — a feature that can be used for more complex architectures. In addition to the server capabilities, Axis provides a few tools that can be used to ease the development effort for server-side and client-side developers. The Java2WSDL tool can used to create Web service specific components for a Java class representing certain functionality. On the other hand, the WSDL2Java utility can be used to generate client-side proxies for the Web service.
Microsoft .NET is a development and deployment platform geared towards Web services. It contains several software technologies that individually address a specific feature necessary for Web service development. As such, several of these software components are upgrades of existing products such as SQL server and BizTalk server. However, under the .NET aegis, these components have a common framework to support Web services. This framework, understandably called .NET Framework, provides the backbone for the Microsoft technologies and products that support Web services. Figure 3.4 depicts that .NET technology stack.
The .NET Framework is essentially an implementation of the Web services technology stack as well as a common set of resources that are used by applications written in any .NET-supported programming language. .NET Framework consists of two parts — the Common Language Infrastructure (CLI) and a set of class libraries. CLI is equivalent to a virtual machine that runs bytecode in an intermediate language called Internal Language (IL). Any language that can be compiled eventually into IL can be supported through the .NET platform.
As part of the .NET platform, Microsoft also introduced a new high-level programing language C# (pronounced See-Sharp). C# integrates programming language concepts in C, C++, and Java; it also has some additional features related to component development.
Visual Studio .NET is the visual programming environment for .NET. From a product perspective, it is the next revision of the Visual Studio Integrated Development Environment (IDE). Visual Studio.NET provides an easy drag-and-drop environment to create Web services from built-in templates. It also automates the process of deploying Web services on Microsoft Web servers.
In Chapters 2 and 4, we introduce the employee portal that enterprises are developing for employees. The portal provides several types of services; one group of services allows employees to manage their company-offered benefits. It is a common practice in many countries to offer employed people a means to save money for their retirement. Typically, these savings are specifically earmarked for the future and are either tax-deferred or tax-free. In the United States, one such company-offered retirement option is the 401(k) plan. Employees can invest up to an Internal Revenue Service (IRS)-defined maximum of pre-tax earnings. This money can be invested either in the offering company’s stock, in more than one mutual fund, or in some other financial instruments (such as a government bond).
Large investment houses provide the participating employers and employees services that can give up-to-date information such as the available mutual funds for investment, the performance of those, and an individual’s real-time account bal-ance. To illustrate a simple Web service, we look at the example of a retirement plan contribution service — Emp401kService()
. This service allows its users to review fund lists and their associated contribution percentages. The service exposes two methods to accomplish this:
getFundList
getEmployeeContribution
In the next section, we demonstrate how to develop and deploy this service using both the J2EE and .NET Web services platforms.
Web services allow a decoupling of the business logic from the deployment. Hence, the first step in developing a Web service is to identify (or create) the business logic which will be exposed via the Web service interface. In our Emp401kService example, the business logic is very straightforward as can be seen from the business logic files Emp401kService.java and Emp401kServiceDOTNET.asmx.cs. Figure 3.5 depicts the service architecture.
The getFundList
method retrieves the list of the selected mutual funds available in this 401(k) plan from a backend database. The getEmployeeContribution
method takes an employee number and returns the mutual funds and associated contribution percentages. Appendix F provides the schema for the 401(k) contribution database. Notice that there is nothing Web service-specific in the business logic code for the most part.
The way our service is architected, it takes character strings as input and returns a string in each case as output, but it could very well have used XML for information sharing. Later, in Section 3.5, we discuss the document exchange paradigm in greater detail.
Once the business logic or service logic is completed, the next step is to deploy it as a Web service. Before we discuss the deployment of the Emp401kService
, let’s recap what the Web services interaction paradigm will look like after deployment.
Notice that in both the .NET and J2EE worlds, the service takes programmatic SOAP-based requests and returns SOAP-based responses. Also, notice that the J2EE service is deployed with the Apache Axis server or J2EE container whereas the .NET service is deployed on Microsoft’s Internet Information Server (IIS). The .NET paradigm is very integrated with Visual Studio .NET. The point and click nature of Microsoft tools masks many of the steps that occur between business logic creation and service deployment. We focus on the J2EE environment and return to .NET towards the end of this section.
Deploying Web services in Axis is supported by a set of utilities that are bundled along with the Apache Axis Web service tools. After developing the business logic, the following steps are required for deploying the business logic as a Web service.
Create the WSDL representation
Create client-side bindings for the Web service
Deploy the business logic as a Web service
Create client logic
After the service is developed, a WSDL representation of it must be created. Many Web service platform vendors have tools that make this step very straightforward and remove the hassle of creating the associated XML.
Axis includes a utility called Java2WSDL.class
in package org.apache.axis.wsdl
to create the WSDL. The Java2WSDL
utility takes several parameters including class representing the Web service, name of the WSDL file, and default namespace. The reader is referred to the Axis User’s Guide for complete list of parameters. In this example, we use following parameters:
Java class name for the business logic
WSDL file name
Service access point URL
Target namespace
Service name
The Java class name is straightforward. In the example, this is Emp401kService()
. The WSDL file name is Emp401kService.wsdl. The service access point URL is the address of the deployed Web service. This is the address at which the service is reachable manually or programmatically. In this example, the endpoint is http://localhost:8080/axis/services/Emp401kService. The localhost:8080
should be changed to denote the server and port where the Axis server is started. The target namespace is the namespace used in the WSDL file. In this case, it is urn:Emp401kService
. The service name is simply the name of the service; in this case, it is Emp401kService()
.
To run the utility, execute the following with the aforementioned parameters:
C:> java org.apache.axis.wsdl.Java2WSDL -o Emp401kService.wsdl -l"http://localhost:8080/axis/services/Emp401kService" -n "urn:Emp401kService" Emp401kService
When this executes successfully, a file called Emp401kService.wsdl is generated in the local directory. So, what does the WSDL file actually do? Let’s take a look at it more closely. The following portion of the WSDL file describes the messages that the service recognizes and processes. In this example, each method requires parameters and returns some data. Hence, there is a pair of messages exchanged when these methods are invoked. It possible that a pair of messages is not exchanged and only a request OR a response is delivered to the service or client, respectively. WSDL supports even these types of methods.
Example . Emp401kService.wsdl
<wsdl:message name="getFundListRequest"> </wsdl:message> <wsdl:message name="getFundListResponse"> <wsdl:part name="return" type="SOAP-ENC:string"/> </wsdl:message> <wsdl:message name="getEmployeeContributionRequest"> <wsdl:part name="in0" type="SOAP-ENC:string"/> </wsdl:message> <wsdl:message name="getEmployeeContributionResponse"> <wsdl:part name="return" type="SOAP-ENC:string"/> </wsdl:message> ...
The following portion of the WSDL file describes the methods (operations) of the service. Notice the pairing together of request-response messages and their relationship to a specific operation.
Example . Emp401kService.wsdl
<wsdl:portType name="Emp401kService"> <wsdl:operation name="getEmployeeContribution" parameterOrder="in0"> <wsdl:input message="intf:getEmployeeContributionRequest" /> <wsdl:output message= "intf:getEmployeeContributionResponse" /> </wsdl:operation> <wsdl:operation name="getFundList"> <wsdl:input message="intf:getFundListRequest" /> <wsdl:output message="intf:getFundListResponse" /> <wsdl:fault message="intf:Exception" name="Exception" /> <wsdl:fault message="intf:ClassNotFoundException" name="ClassNotFoundException" /> </wsdl:operation> </wsdl:portType> ...
The last portion of the WSDL file includes the parameters we provided in creating the WSDL representation, namely, the service access point URL and the service name.
To interact with a Web service, the client environment needs to have a client-side proxy for the service. The client-side proxy classes are responsible for exchanging messages with the service instance.
Axis provides a tool to generate the client-side stubs (the Web service proxy). Find the Web service business logic class file (in our example, Emp401kService.class) and run the following command:
C:> java org.apache.axis.wsdl.WSDL2Java -s -Nhttp://localhost:8080/axis/services/Emp401kService =Emp401kService -Nhttp://DefaultNamespace=Emp401kService Emp401kService.wsdl
The WSDL URL is used by this tool to generate the appropriate messaging syntax. The -N
option specifies the mapping between a namespace and a package. In this example, both the namespaces are mapped to the same package, viz. Emp401kService()
. The directory, Emp401kService, has the following client proxy files:
Emp401kService.java
Emp401kServiceService.java
Emp401kServiceServiceLocator.java
Emp401kServiceSoapBindingStub.java
deploy.wsdd
In addition to these files, Java code representing exceptions and certain server-side bindings are also generated. The file deploy.wsdd is used during Web service deployment.
Before the service is ready to be deployed, all necessary business logic classes need to be made available to the Axis SOAP server. To accomplish this, make all the Web service classes available in the class path.
At this point, the environment is set to deploy and run the service, Emp401kService()
. Start the Axis server with following command:
C:> java org.apache.axis.transport.http.SimpleAxisServer -p 8080
To deploy the Web service, the Axis Admin client tool is used. This tool uses the file deploy.wsdd. Sample contents of this file is shown below:
Example . deploy.wsdd
<deployment> <!-- Services from Emp401kServiceService WSDL service --> <service name="Emp401kService" provider="java:RPC"> <parameter name="className" value="Emp401kService.Emp401KServiceSoapBindingSkeleton"/> <parameter name="allowedMethods" value="*"/> <parameter name="scope" value="Session"/> </service> </deployment> C:> java org.apache.axis.client.AdminClient deploy.wsdd
The simplest way to ensure that the service is deployed appropriately (from a client perspective) is to enter the URL for the WSDL in the browser — http://localhost:8080/axis/services/Emp401kService?wsdl. The WSDL file for the Emp401kService()
is depicted in Figure 3.6.
The client logic should be part of the same service proxy package as follows:
Invoking the exposed Web service methods involves exchanging the SOAP messages described in the WSDL file. The method, Emp401kServiceServiceLocator()
, provides the instance to the class that facilitates this communication. Individual methods from this class, Emp401Service()
, correspond to methods of the original service. Therefore, the following code segment invokes the getFundList()
method of the Emp401kService()
.
To observe the example code in action, start the Axis SOAP server. We assume that the service has been deployed and the installation is verified. Open a command window and, from the appropriate directory, start the client program as follows:
C:> java Emp401kService.Emp401kClient
The menu will appear as shown in Figure 3.7. To view the list of funds available, choose option 1. Contributions for a specific employee can be found through option 2. The list will appear as shown in Figure 3.8.
Web services development in .NET can be completely contained within the Visual Studio .NET development tool. While developers on the Microsoft platform can manually create their .NET Web services without the help of the integrated development environment (IDE), our discussion is based on creating the Emp401k service with the help of the IDE.
First off, either the Internet Information Server (IIS) or the Personal Web Manager (PWM) is needed to run the Web services. The J2EE platform is application server-based and Web services run in the application server. However, in the .NET paradigm, Web services run in the Web server as an extension to the Active Server Pages (ASP) technology. Start the Web server as it is required when developing and building .NET Web services.
Once installed, start Visual Studio .NET from the Start
menu. Start a new project from the File
menu. On the right-hand side, choose the programming language; for this example we use C#
. However, ensure that the ASP .NET Web service
template is selected and that the name of the Web service is provided in the Location
box at the bottom of the dialog box. We have named this one: Emp401kDOTNET()
. Figure 3.9 depicts this step.
As the IDE processes this new Web service, a familiar graphic as seen in Figure 3.10.
The result of this process is that (assuming that PWM or IIS is installed with its default configuration) a new directory with the name of the Web service is created in C:
Inetpub
wwwroot
. In this case, recall that it is Emp401kDOTNET. Check to make sure that this directory is created and also change the Web sharing properties on this directory. Right click on the directory name and go to the Web Sharing
tab. Select Share this Folder
check box. A property dialog box will immediately pop up and the following should be selected:
Read
Write
Execute
Figure 3.11 depicts this step.
At this point, we are ready to modify the .NET Web service template to create the Emp401kDOTNET()
Web service. Select the Service1.asmx in the Solution Explorer and rename it to the service name — in this case, Emp401kDOTNET.asmx. Also right click this file and set it as the start page for the service. Modify the template to add the required business logic. Emp401kDOTNET.asmx is the main Web service business logic file of the Web service.
Recall from the J2EE example that we use a database backend for this Web service. In the .NET paradigm, this requires having ODBC .NET Manager
installed in the environment. Download and install this from Microsoft Developer Network (MSDN) Web site. We provide a shortcut to this URL on the accompanying CD. Once this is installed, include the database access libraries: Microsoft.Data.Odbc
and System.Text
in the asmx
file. In addition, add reference to the ODBC library from the Project
→ Add Reference
→ Microsoft.Data.ODBC.dll
.
Develop the business logic, similar to that in the J2EE paradigm, for getFundList()
and getEmployeeContribution()
methods.
Exposed Web service methods in .NET Web services need to be public
and should be denoted as a WebMethod
.
Take a look at the code for the getFundList()
method:
Example . Emp401kDOTNET.asmx.cs
[WebMethod] public string getFundList() { DataSet dataset= new DataSet(); OdbcDataAdapter adapter = new OdbcDataAdapter(); adapter.SelectCommand = new OdbcCommand("SELECT FundName FROM FundTable", myconn); adapter.Fill(dataset); StringBuilder resultString = new StringBuilder(); //iterate through the resultant dataset and build result string for(int i=0; i<dataset.Tables["Table"].Rows.Count; i++) { resultString.Append(dataset.Tables["Table"]. Rows[i]["FundName"]); resultString.Append("|"); } //Return the result in String format return resultString.ToString(); }
The code looks fairly straightforward. There is generated code and template code that takes care of the Web services aspects of the development. For example, the InitializeComponent
is included in the Web service constructor. Business logic is added to this template to provide the desired functionality via the Web service. A Build
of the solution creates the relevant Web service specifics. Recall that we ran the ClassToWSDL
tool in the WSP to create the WSDL file; in this case, this step is included in the build process.
To deploy the .NET based service from Visual Studio .NET IDE, load the project in the IDE environment. To deploy the Web service and launch the default browser-based client, click on Debug
→ Start Without Debugging
. Successful operation will launch the browser as shown in Figure 3.12.
Notice http://localhost/Emp401kDOTNET/Emp401kDOTNET.asmx, the Web service URL, which is based on the Web service name. To view the WSDL of the Web service, enter the following URL in the browser or click on the Service Description
link on the default page:
http://localhost/Emp401kDOTNET/Emp401kDOTNET.asmx?WSDL
The WSDL document is displayed in the browser window as shown in Figure 3.13.
To invoke any service method, click on its name on the default page. A page detailing the SOAP messages and HTTP request examples will appear along with the Invoke
button. The page for the getFundList()
method is shown in Figure 3.14.
Clicking on the Invoke
button invokes the particular method for the service and displays the results. The resultant page after invoking the getFundList()
method is shown in Figure 3.15.
Until now, we treated the information to and from the Web service in the form of objects. In such a case, the information is stored in the form of Java or C# objects at both ends.
In Chapter 5, we discuss how language-specific data representation limits interoperability. Generally, it would be desirable to represent and process the data in XML format to improve it. Services developed using the Document Exchange Model (DEM) are designed to maximize usage of XML.
DEM-based services are most suitable for interactions that are request-response in nature where both the request and response are potentially complex in nature. Examples of such interactions are the exchange of order information between a company and its customers or an intracompany communication of product configuration data for complex products such as a car or an airplane. Figure 3.5 depicts simplified versions of such interactions.
In these types of interactions, language-specific objects are more difficult to work with compared to structured XML documents. XML documents provide a very flexible way to share information. SOAP and WSDL, based on XML technology themselves, provide a means to communicate information using XML documents.
Consider a DEM-based retirement plan contribution service that accepts XML-formatted requests and provides XML-formatted responses in contrast to the services explained previously that took string
inputs. The request document to get contributions of an employee with ID 1001 could be formatted as follows:
<getEmployeeContribution xmlns="insidewebservices.com"> <EmployeeID> 1001 </EmployeeID> </getEmployeeContribution>
In response to such a request, the service returns an XML document that provides the fund names the employee has contributed to and the associated contribution percentage for each fund. For example:
<ContributionInfo xmlns="insidewebservices.com"> <EmployeeName> Carl Cooper </EmployeeName> <FundList> <Fund> <FundName> Growth and Income Fund </FundName> <contribPercent> 50.0 </contribPercent> </Fund> <Fund> <FundName> Tax-Free Investment Fund </FundName> <contribPercent> 50.0 </contribPercent> </Fund> </FundList> </ContributionInfo>
Note that in both the XML documents, the structure of the document is defined in a rather ad-hoc manner. In reality, there would more standard formats defined for such documents. In addition, elements do not have any attributes since they are discouraged in the WSDL specification in order to increase interoperability.
In the request and response messages sent using SOAP, a service developer has two options to package relevant XML documents. The XML documents can be embedded in the SOAP body or it could be attached to the SOAP message as an attachment.
Embedding an XML document in a SOAP message is a simpler option in which the relevant XML document is packaged within the SOAP body element and eventually in a SOAP envelope before the message is sent to/from the service. Due to this, the entire XML document becomes a “node” within the SOAP message (which is in XML format itself). Figure 3.16 depicts this.
Thus, a SOAP-based request for employee contribution could look like this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getEmployeeContribution xmlns="insidewebservices.com"> <EmployeeID> 1001 </EmployeeID> </getEmployeeContribution> </soap:Body> </soap:Envelope>
The SOAP specification allows for attachments to SOAP messages as explained in Appendix G. In such a case, SOAP messages could be sent in multipart Multi-Purpose Internet Mail Extensions (MIME) format. The main SOAP envelope forms one part of the MIME-structured message. The XML document(s) associated with the main SOAP message are packaged as remaining parts of the message with a reference to each such attachment in the main SOAP message. Figure 3.17 depicts this message structure.
The <Attachment>
tag in a SOAP body (or header) is used to specify references any attachments associated with the specific part of the SOAP message. This reference is in the form of a Universal Resource Identifier (URI) and is specified using the attribute href
. A response to the getEmployeeContribution
request can thus be formatted as follows:
--MIME encapsulation boundary Content-Type: text/xml <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <Attachment href="http://insidewebservices.com/ctrbRes.xml"/> </soap:Body> </soap:Envelope> -- MIME encapsulation boundary Content-Type: text/xml Content-Location: http://insidewebservices.com/ctrbRes.xml <?xml version="1.0"?> <ContributionInfo xmlns="insidewebservices.com"> <EmployeeName> Carl Cooper </EmployeeName> <FundList> <Fund> <FundName> Growth and Income Fund </FundName> <contribPercent> 50.0 </contribPercent> </Fund> <Fund> <FundName> Tax-Free Investment Fund </FundName> <contribPercent> 50.0 </contribPercent> </Fund> </FundList> </ContributionInfo> -- MIME encapsulation boundary--
Although more esoteric from a development perspective, SOAP messages with XML attachments provide a clear partition between information and its packaging. In addition, this technique can be used to package several related XML response documents into one MIME package as attachments to the SOAP response message.
To develop and use a DEM-based service, the service or its clients may have to generate SOAP messages themselves as the level of automation in the existing tools lacks the necessary sophistication. The Java APIs for XML Messaging (JAXM) objects can alleviate the developer from creating the necessary element structure to convert an existing XML document into a SOAP message. Refer to JAXM literature for more details.
The description of a DEM-based service differs slightly from an RPC-based service. In a WSDL document that describes a DEM-based service, several elements denote the fact that the service interacts through structured XML documents rather than built-in data types such as int
and string
.
The XML documents used by a service, to receive requests or provide responses, are described in its WSDL document as complexType
elements. A complexType
element looks very close to an XML Schema Document (XSD) for an XML file. The ContributionInfo
response document can be represented in the WSDL document as follows:
... <definitions xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://insidewebservices.com"> ... <s:complexType name="ContributionInfo"> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="EmployeeName" type="s:string" /> <s:element minOccurs="1" maxOccurs="1" name="FundList" type="s0:FundList" /> </s:sequence> </s:complexType> <s:complexType name="FundList"> <s:sequence> <s:element minOccurs="1" maxOccurs="unbounded" name="Fund" type="s0:Fund" /> </s:sequence> </s:complexType> <s:complexType name="Fund"> <s:sequence> <s:element minOccurs="1" maxOccurs="1" name="FundName" type="s:string" /> <s:element minOccurs="1" maxOccurs="1" name="contribPercent" type="s:string" /> </s:sequence> </s:complexType> ... </definitions>
The document-oriented nature of a service in WSDL is denoted in two places — binding
and operation
. In both these elements, the attribute style
denotes the type of service. For DEM-based services, this attribute should be set to the value document
. Thus, to denote the retirement plan contribution service as DEM-based, the corresponding elements are:
... <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> ... <soap:operation soapAction="http://soapinterop.org/" style="document" /> ...
Many Web service development tools available provide capabilities to create DEM-based services.
A Web service developer must be well versed in several aspects of Web service architecture. The discussion in this chapter is limited to providing an overview of the Web services technology. Using this discussion, it is possible to create simple Web services that can be used to understand the applicability of UDDI in the service lifecycle. As Web services evolve to solve real business issues and become mission critical and production-ready in nature, there are several other issues that need to be considered.
The scalability of a Web service is determined by how well it can satisfy an increasing number of concurrent client requests. The higher the number of concurrent requests that a service can handle, the better the scalability. Of course, a single instance of a service has severely limited scalability. The deployment platform significantly affects the scalability of a service. Some deployment platforms use an application server in their infrastructure that have built-in load balancing capabilities. If a Web service platform deploys the service as a servlet or an Enterprise Java Bean (EJB), the scalability is limited by the load-managing capabilities of the underlying servlet or EJB container.
One of the promises of Web services is their ability to simplify intercompany interaction. These interactions are typically long-lived — the interactions take several hours or days to complete and generally include several round trip sub-interactions. An object-oriented (or RPC-based) approach to develop the service logic, for such a scenario, is not suitable since, generally, objects are not expected to exist that long.
A DEM-based service can provide a suitable alternative to facilitate long-lived interactions. The architecture for incorporating DEM-based services in long-lived interaction is currently undergoing evolution. After the architecture and related technologies mature, Web services can be very effective in managing long-lived interaction in both intra- and intercompany situations.
Security is a vast area that has not been fully addressed by many of the Web service platforms at this point. For business-critical applications, Web service security needs to address several issues including, but not limited to:
Access to the service: who has authority to use the service
Access to different methods of the service: who has what levels of authority on the service methods
Access to the user data to and from the service: who has access to view and comprehend the data and information flowing to and from the service
Access to the user: who has authorization to communicate with the service user and access user information and data
Access to the architecture or internal process flows: who has authorization to introspect and extract the business processes that are used by the service
Several standards are being proposed to address one or more of the aforementioned issues. Notable among these standards are W3C XML Encryption, W3C XML Signature (also known as the “digital signature”), Java Security Assertion Markup Language (JSAML), Web Services Security (WS-Security), XML Key Management Services (XKMS), and XML Access Control Markup Language (XACML). The HP-WSP implements the digital signature specification. Most recently, IBM, Microsoft, and Verisign announced a supporting initiative in Web services security. Web Services-Security (WS-S) describes enhancements to the SOAP technology to provide quality of protection through message integrity, message confidentiality, and single message authentication. WS-Security also provides a general-purpose mechanism for combining security tokens with SOAP messages. It is designed to be extensible (e.g., support multiple security token formats). While many initiatives support the security requirements of Web services, as yet, no specific standard has been widely adopted.
UDDI plays an important role in the Web services paradigm. UDDI is the business registry that facilitates the discovery and interaction of Web services. It has become a de facto standard, like SOAP and WSDL. The key to begin participating in the UDDI infrastructure is to model your business. This model includes not only compiling the business entity information but also determining the services, tModels, and bindingTemplates to be registered as well. In the next chapter, we discuss business modeling in detail.