Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

IBM WebSphere Application Server configuration

Introduction to programming for XML Config

Maheshwar Rao (maheshwarr@is3c.com), WebSphere Consultant, iS3C Consultancy Services Pvt.Ltd.
Maheshwar is a computer engineer currently working as a WebSphere Consultant in iS3C. He is experienced in 3-tier WCS configuration with Network Dispatcher on AIX, and has worked on MCIS 2.5 systems. Maheshwar is now fascinated by Web services in WebSphere. You can contact him at maheshwarr@is3c.com.

Summary:  This article shows you how to write Java code that you can use with the XML Config API provided in IBM WebSphere Application Server. You can use the sample code included to create a secure, restricted Web-based interface that can fully administer an instance of WebSphere Application Server on a server with multiple application server instances: a situation where remote invocation might not be wise.

Date:  01 Jan 2002
Level:  Advanced

Activity:  3865 views
Comments:  

XML's role in WebSphere Application Server

IBM WebSphere Application Server provides XML document structure services with a document parser, document validator, and document generator for server-side XML processing. When you install WebSphere Application Server, the core XML APIs are automatically added to the appropriate class path, letting you serve static XML documents as soon as the product is installed. To serve dynamically-generated XML documents, use the core APIs to develop servlets or Web applications that generate XML documents. For example, the applications might read the document content from a database. Then deploy those components on your application server.

WebSphere Application Server supports the following XML/XSL APIs:

  • XML4J Version 3.1 or Xerces Version 1.2.1
  • LotusXSL Version 2.0 or Xalan Version 2.0.1

The components of XML for Java provide support for parsing, validating, and generating XML data. The processor implements the base XML, namespace, and DOM W3C recommendations and SAX de facto standard.

Intro to XML Config

WebSphere Application Server supports XML and allows you to configure its resources using XML documents. WebSphere Application Server understands all the XML documents that conform to WebSphere Application Server Configuration Markup Language Syntax. This concept is known as XML Config. XML Config can be a complete replacement for the administrator console of WebSphere Application Server.

One of the strengths of WebSphere Application Server is its flexibility. You can use a simple XML file to configure an instance of the server. XML Config is one of the most powerful administration applications available for WebSphere Application Server because:

  • It has full administrative function
  • It has a command line interface
  • It lets you save configuration changes and apply them later
  • It's possible to write applications related to high-level administration and configuration with any desired functions
  • You can create a good Web-based interface using the XML Config API provided with WebSphere
  • You can use write custom Web-based administration applications to give you flexible remote configuration.

Ways to use XML Config

You can use XML Config for many different types of tasks, such as:

  • Configuring an instance of WebSphere Application Server with the help of an XML file.
  • Easing migration; it is very handy, when you want to configure a server the same way as another server, just to import the XML file to the second server. (For example, you deleted a server and need to configure one similarly to the deleted one with little or no changes.)
  • Fine-tuning the application server by just importing an XML file with parameters and their values specified.
  • For complicated and sophisticated administration tasks such as cloning.
  • Using WebSphere Commerce Suite (WCS) V5.1. For example, you can create an instance of WCS using XML Config.
  • Creating customizable Web-based administration applications.

Command line

You can use XML Config to import and export configuration data to and from the WebSphere Application Server administration repository. This XML-based approach complements the administration you can do through the WebSphere administrative console. You can use the command line to make multiple changes to the WebSphere Application Server administration repository at one time without going through the repetitive routines on the administration console. You can also use this tool to extract the repository information from a server and import it onto a cloned server.

The XML Config tool provides three fundamental features:

Full export
Generates an XML document describing the configuration of the entire administrative domain. In effect, the full export takes a "snapshot" of the administrative repository contents.
Partial export
Provides an XML document specifying administrative objects to export from the administrative domain. The objects and their children are exported to an XML document that you specify.
Import
Imports a newly created XML document or a document you previously exported and modified. In the XML document, you can add, modify, or remove administrative objects such as servlets and virtual hosts. Your XML document can replace the administrative repository contents partially or entirely.
xmlconfig {( -import <xml date file>) ||
		[ ( -export <xml output file> [ -partial <xml data file>] ) }
		- adminNodeName <primary node name>
		[- nameServiceHost <hostname> [- nodeServicePort <port number>] ]
		[- substitute <"key1=value1[;key2=value2[;..]]">  ] 


The above command line utility has full administrative functions, but it's not possible to do remote configuration. However, the following approach extends the usability of XML Config even over the Internet.

Writing an XML Config application

The xmlconfig.dtd file has XML specifications for XML Config. This file is also used for error and syntax checking of imported XML files.

a) system.root=WAS_HOME (example 'C:/WebSphere/WAServer')
b) XMLConfigDTDLocation=XMLConfigDTD_File_Location (example 
'C:/WebSphere/WAServer/bin')

DOCTYPE websphere-sa-config SYSTEM C:/WebSphere/WAServer/bin/xmlconfig.dtd

In the case of the command line utility, in XMLConfig.sh/.bat the first parameter passed to the Java application is server.root. The DTD file location for WASCML is set through the above-mentioned statement. You can also set the location in your program by using the following statements.

if(System.getProperty("server.root") == null){
     try{    
          System.getProperties().put("server.root","C:/WEBSPH~1/WAServer");
          }
     catch(Exception e){
          System.out.println("Exception to set server.root" + e);
	     }
}
if(System.getProperty("XMLConfigDTDLocation") == null){
     try{	               
          System.getProperties().put("XMLConfigDTDLocation",
          "C:/WEBSPH~1/WAServer/bin");
          }
     catch(Exception e){
          System.out.println("Exception to set XMLConfigDTDLocation" + e);
          }
}

You need to import the following classes from the package com.ibm.websphere.xmlconfig. (This is the same API that's used in the command line utility, provided in the WAS_HOME/bin directory.)

import com.ibm.websphere.xmlconfig.*;
import com.ibm.xml.parser.*;
import org.w3c.dom.*;

Now instantiate an object of an XML Config class as follows. There are three different constructors available for the class com.ibm.websphere.xmlconfig XMLConfig.

  • public XMLConfig(java.lang.String adminNodeName, boolean _advanced) throws javax.naming.NamingException
  • public XMLConfig(java.lang.String adminNodeName, boolean _advanced, java.lang.String nameServiceHost, int nameServicePort) throws javax.naming.NamingException
  • public XMLConfig(java.util.Hashtable args) throws InvalidArgumentException, javax.naming.NamingException

Set parameter _advanced to true if you are using WebSphere Application Server Advanced Edition, or to false if not.

Below is an example of the third constructor.

Hashtable arg = new Hashtable();
arg.put("-adminNodeName","mahi");
XMLConfig wasObj = new XMLConfig(arg);
String xmlFile = "export.xml";     // File to hold XML returned by	               
 				   // XMLConfigFile 
// Create a file to hold the XML configuration
File xmlConfig = new File(xmlFile);
FileWriter xmlExport = new FileWriter(xmlConfig);

Example of full export

You must get the output from the repository as a DOM object and then convert the object into an XML file. The following statements get the output from the repository as a DOM object:

  • TXDocument wasxml = null;
  • wasxml = was.executeFullExport();

The following statement converts the DOM object output into XML format and puts it in the file mentioned previously:
wasxml.printWithFormat(xmlExport);

Conclusion

The XML Config API gives you the flexibility to easily develop complicated administration and configuration applications. Configuration situations are not always simple. Imagine there is more than one development team working on a single box that has WebSphere Application Server with multiple instances, or sharing a WebSphere Application Server environment. Applications using XML Config can keep developers away from places where they shouldn't wander. Now it's not required for development teams to log on to the server or use the WebSphere Application Server console. The WebSphere Application Server administrator console can be invoked remotely, but it has no security to restrict the resources you can administer. Using the utilities described in this article gives developers a simple Web interface to do everything they need to without accessing the server or the adminstrator console remotely.

XML Config API applications are also useful to write automated migration processes that let developers deploy to production systems. You can use XML Config in complicated situations like cloning for configuration purposes. XML Config programming applications could be extremely useful for ISPs who are into shared Web hosting on WebSphere Application Server.


Resources

About the author

Maheshwar is a computer engineer currently working as a WebSphere Consultant in iS3C. He is experienced in 3-tier WCS configuration with Network Dispatcher on AIX, and has worked on MCIS 2.5 systems. Maheshwar is now fascinated by Web services in WebSphere. You can contact him at maheshwarr@is3c.com.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Sample IT projects
ArticleID=10170
ArticleTitle=IBM WebSphere Application Server configuration
publish-date=01012002
author1-email=maheshwarr@is3c.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).