JWSDP consists of software, tools, and a set of APIs that Sun Microsystems, Inc. provides. You can use these components of JWSDP to develop, deploy, and test Java Web services.
While you're unpacking and installing the JWSDP package, you are prompted for a username and a password. You need to provide this username and password (see Figure) while you deploy the application in the Tomcat container.
The Interface for Accepting the Username and Password
However, if you forget your username and password, you can look up the tomcat-users.xml file to find them. You will learn more about the tomcat-users.xml file in the later section "Authenticating Users to Access Web Services."
You need to install Java2SDK Standard Edition version 1.3.1_03 or later to be able to use JWSDP. After you have installed the JWSDP toolkit, you need to set the following paths:
JWSDP consists of the following components:
JSPs are dynamic Web pages that are executed at a server. A JSP page contains Java code scriptlets that are executed during runtime. The output of execution of Java scriptlets is displayed on the client Web browser. You can write the code for scriptlets to perform numerous tasks, such as accessing databases, performing numerical calculations, and so on.
Many tasks are common across JSP applications. To perform such common tasks, you are provided with a set of standard tags that work the same way everywhere. These tags are packaged in Java Server Pages Standard Tag Library (JSTL).
JSTL contains tags for performing tasks that include editing XML documents, querying databases, performing iteration, performing conditional operations, and so on. JSTL also enables you to integrate existing tag libraries with JSTL.
JSTL uses multiple Tag Library Descriptors (TLDs) to specify a namespace and its functionality. You can categorize the tags in JSTL into the following divisions:
You can use a JSTL core tag in a JSP page by using the taglib directive, as shown in the following example:
In a web.xml file, TLDs are referenced by using the following code snippet:
JSTL tag libraries are available in two versions:
These libraries differ in the way they support the use of runtime expressions. Expressions are specified in a scripting language by the tags in the JSTL-RT tag library. In contrast, for the tags in the JSTL-EL tag library, expressions are specified in the JSTL expression language. The naming conventions of the TLDs in both the libraries are as follows:
You can find the JSTL TLDs in JWSDP in the directory <JWSDP_HOME>/tools/jstl/tlds.
To enable a Web application to use the tag libraries, you need to ensure that the JSTL API is available to the application. In addition, you must ensure that the application can implement the API.
JWSDP provides you with JSTL API and its implementation in the form of the archives jstl.jar and standard.jar. The jstl.jar archive is available in the <JWSDP_HOME>/tools/jstl directory. You can access the standard.jar archive from the < JWSDP _HOME >/tools/jstl/ standard directory.
The JSTL API defines some implicit objects for JSP. These implicit objects are as listed:
You can refer to these implicit objects by using the following syntax:
In the preceding example, the number of items in the current session is being evaluated.
JWSDP Registry Server
Another important component of JWSDP is the JWSDP registry server. You need to register the Web services that you create and deploy so that a client is able to access them. To enable registration of Web services, JWSDP provides you with the JWSDP registry server. The registry server provides UDDI registry for Web services in a private environment.
You can use the registry server to test the applications that you develop by using the JAXR API. The registry server includes the following components:
Starting the Registry Server
Before you use the registry server, you need to start both Tomcat and the Xindice database. To start Tomcat, execute the following command at the command prompt:C:> startup
You can execute this command from any directory if you have set the environment variable PATH to <JWSDP_HOME>/bin.
To verify that the Tomcat server has started, type the following address in the address bar of the Web browser:http://localhost:8080
To start the Xindice database, execute the following command:Xindice-start
To stop the Xindice database, execute the following command:Xindice-stop
The registry server provides a shell script to perform the following tasks:
The Indri tool provides a GUI interface to access the registry server database. To start the Indri tool, execute the following command at the command prompt:
The output is displayed in Figure.
The Output of the Command to Run Indri
The GUI interface of Indri is displayed in Figure.
The GUI Interface of Indri
Working with Service Registries by Using JAXR
Service registries allow you to publish, access, and use Web services. Service brokers host Service registries that can implement different registry standards, such as UDDI, OASIS, and ebXML.
Microsoft and IBM provide registries that implement UDDI Version 2. You can use these test registries to publish your service.
In Java, you can use different applications to publish or access registered services. These registered services can implement different registry standards. JAXR helps you work with disparate registries. For example, you can use JAXR in your application to search for services in the IBM registry. Similarly, you can use JAXR to publish your service and manage your service data in some registries that might implement other registry standards.
The following two packages are used to encapsulate the complexities of working with
registries in the Java service model:
To use JAXR in your application, you need to import these packages.
We will now discuss the code sample that uses JAXR. When you create an application, you need to create an instance of the Properties class, which specifies the URL of the UDDI registry. Instead of the UDDI registry, you can specify the URL of the IBM test query registry:
Next, you can create an instance of the ConnectionFactory class, as shown in the following code:
You need to obtain a BusinessQueryManager object for performing simple queries. To obtain the BusinessQueryManager object, you first need to obtain the RegistryService object. The following code discusses how to obtain the RegistryService object and use it to create an object of the BusinessQueryManager type:
To query an UDDI registry for an organization, you can use the findOrganization() method. The usage of the findOrganization() method is shown in the following code:
Observe in the code that the findOrganization() method returns a BulkResponse object. The BulkResponse object is used to obtain the Collection objects. After you obtain the Collection objects, you can iterate through these objects to locate the Organization object.
In the preceding code, notice the add() method. You can hard-code the organization name you want to query in the add() method. Alternatively, you can use a command-line argument that represents an organization name.
The following code shows how to locate the Organization object:
After you locate the Organization object, you can use it to obtain a collection of the services that the organization offers. The following code prints the service information and shows how you can obtain the service information:
In addition to querying registries, you can perform simple queries on registries and use JAXR in your application to register your service in a registry. You can also delete your service from a registry by using JAXR.
XML Documents by Using JAXP
In the Java service model, information is exchanged in the form of XML documents. Therefore, developers for the Java service model often need to process XML documents from with in Java applications. JAXP enables developers to easily access, process, and transform XML documents.
As you know, JAXP parses the XML documents by using the SAX or DOM parsers. JAXP encapsulates the complexities of using SAX and DOM APIs from Java applications to parse XML documents.
JAXP also enables you to switch effortlessly between different vendor-specific parsers. You can switch between parsers without needing to recompile your Java application. JAXP also supports the format transformation of XML documents by using XSLT.
To process XML documents by using JAXP, you need to perform the following steps:
We will now discuss the content of these files.
The code of the organization.dtd file is as follows:
The code of the organization.xml file is as shown:
To parse the XML document and display the result, create a Java class with the name OrganizationInfo. The packages that you need to import are as listed:
The OrganizationInfo class extends the DefaultHandler class. In the OrganizationInfo class, you need to implement the required callback methods that the parser calls. The following code illustrates the implementations of the required callback methods:
Next, create an object of the OrganizationInfo class in the main() method of the OrganizationInfo class. Then create an instance of the SAXParser class. Using this instance, parse the XML document, organization.xml. The following code illustrates the main() method of the OrganizationInfo class:
Compile and run the OrganizationInfo class.
Performing Service Message Transactions by Using JAXM
As discussed JAXM enables you to create, send, and receive SOAP messages. JAXM conforms to SOAP version 1.1 and SOAP with Attachment specifications.
A JAXM client can use a messaging provider, which is a service that transmits messages. JAXM provides the following packages to perform messaging in the Java service model:
In the applications used, you provide the URL of the receiver of a message. The SoapConnection object obtains a connection directly to the receiver. The SoapConnection object is obtained from the factory class SoapConnectionFactory.
The code for specifying the URL of the receiver and obtaining a connection is shown in the following snippet:
After you obtain a connection, you need to create a SOAP message. You then obtain the various parts of the SOAP message to add your message content. The following code illustrates how to add contents to a SOAP message:
After you add contents to the SOAP message, save the message and send it to the receiver. The following code illustrates how to send the SOAP message to a receiver:
You can use the SOAPMessage object to print the receiver's response.
XML Related Interview Questions
|Soap Tool Interview Questions||HTML Interview Questions|
|PHP Interview Questions||ASP.NET Interview Questions|
|PHP5 Interview Questions||Java Interview Questions|
|CSS Interview Questions||XSLT Interview Questions|
|Java XML Interview Questions||XMLHttpRequest (XHR) Interview Questions|
|ebXML Interview Questions||XML DOM Interview Questions|
|XML-RPC Interview Questions||XSD Interview Questions|
|Soap Web Services Interview Questions||XSL Interview Questions|
|Xml Publisher Interview Questions|
Basics Of Xml
Basics Of Web Services
Introduction To Soap
Introduction To Uddi
Introduction To Wsdl
Creating A Web Service Using The Microsoft Soap Toolkit
Building Web Applications On The .net Platform
Creating An Asp.net Web Service
Creating A Web Service From An Interface
Introduction To The Atl Server
Creating A Web Service Using The Atl Server Library
Design And Creation Of The Knowledge Share Web Service
Introduction To Java Xml Technologies
Developing Java Web Services
Design And Creation Of A Web Service Using The Ibm Toolkit
Introduction To Mobile Applications
Creating A Mobile Application That Consumes A Web Service
Web Services Development With Jdeveloper
Creating Web Services Using Perl
Integration Of Xml Web Services With The Office Xp And Sql
Server 2000 Toolkits
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.