Axis : 远去前的备忘

1, 使用


1.1 axis本身可以servlet的形式集成到任何支持servlet的Web容器(web.xml)


        <display-name>Apache-Axis Servlet</display-name>




1.2 当然需要让Web容器找到 org.apache.axis.transport.http.AxisServlet

    将axis所需库和资源配置到classpath里面, 或者将axis的lib目录拷贝到WEB-INFO下

1.3 然后让axis接管WebService的url(web.xml)









1.4 剩下的只需要告诉axis每个WebService对应着哪个Java类即可(server-config.wsdd(与web.xml同目录))

    <service name="OrganizationWebService" type="" provider="java:RPC" style="rpc" use="encoded">

        <parameter name="scope" value="Request" />

        <parameter name="className" value="nucleus.organization.webservice.OrganizationWebService" />

        <parameter name="allowedMethods" value="isValid, personOfID, personsOfRole, queryCategories, queryPersons" />


        <typeMapping encodingStyle="" qname="ns1:CategoryInfo"




                     name="CategoryInfo" xmlns:ns1="http://webservice.organization.nucleus" />



2, 配置与扩展


2.1 Handlers

2.1.1 Query String Handlers

By default, Axis provides for three Axis servlet query string handlers (?list, ?method, and ?wsdl).

2.1.2 Some Default Handlers


Wrapper around JAX-RPC compliant handlers that exposes an Axis handler interface to the engine.


A Handler which sends the request message to a remote server via HTTP, and collects the response message.


A Handler which sends the request message to a "local" AxisServer, which will process it and return a response message. This is extremely useful for testing, and is by default mapped to the "local:" transport. So, for instance, you can test the AdminClient by doing something like this:

% java org.apache.axis.client.AdminClient -llocal:// list

2.1.3 Service, Targeted Chain, and Provider

A service is a special kind of Targeted Chain in which the pivot Handler is known as a "provider".


2.2 Configuration

2.2.1 Engine Configuration

The EngineConfiguration interface is the means of configuring the Handler factories and global options of an engine instance. An instance of a concrete implementation of EngineConfiguration must be passed to the engine when it is created and the engine must be notified if the EngineConfiguration contents are modified. The engine keeps a reference to the EngineConfiguration and then uses it to obtain Handler factories and global options.

The EngineConfiguration interface belongs to the Message Flow subsystem which means that the Message Flow subsystem does not depend on the Administration subsystem.

The EngineConfiguration is provided by an implementation of the interface org.apache.axis.EngineConfigurationFactory, which currently provides methods that return client and server configurations.

Our focus will be how to define the implementation class for EngineConfigurationFactory.

  • Justification/Rationale
    While the default behaviour is sufficient for general use of Axis, integrating Axis into an existing application server may require an alternate deployment model. A customized implementation of the EngineConfigurationFactory would map from the hosts deployment model to Axis's internal deployment model.

  • Mechanism
    The relevant sequence of instructions used to obtain configuration information and initialize Axis is as follows:

    EngineConfigurationFactory factory = EngineConfigurationFactoryFinder(someContext);
    EngineCongfiguration config = factory.getClientEngineConfig();
    AxisClient = new AxisClient(config);

The details may vary (server versus client, whether other factories are involved, etc). Regardless, the point is that integration code is responsible for calling EngineConfigurationFactoryFinder(someContext) and ensuring that the results are handed to Axis.  someContext is key to how the factory finder locates the appropariate implementation of EngineConfigurationFactory to be used, if any.

EngineConfigurationFactoryFinder works as follows:

  • Obtain a list of classes that implement org.apache.axis.EngineConfigurationFactory, in the following order:

    • The value of the system property axis.EngineConfigFactory.

    • The value of the system property org.apache.axis.EngineConfigurationFactory.

    • Locate all resources named META-INF/services/org.apache.axis.EngineConfigurationFactory. Each line of such a resource identifies the name of a class implementing the interface ('#' comments, through end-of-line).

    • org.apache.axis.configuration.EngineConfigurationFactoryServlet

    • org.apache.axis.configuration.EngineConfigurationFactoryDefault

  • Classes implementing EngineConfigurationFactory are required to provide the method  

    public static EngineConfigurationFactory newFactory(Object)

This method is called, passing someContext as the parameter.

The newFactory method is required to check the someContext parameter to determine if it is meaningfull to the class (at a minimum, verify that it is of an expected type, or class) and may, in addition, examine the overall runtime environment. If the environment can provide information required by an EngineConfigurationFactory, then the newFactory() may return in instance of that factory. Otherwise, newFactory() must return null.

EngineConfigurationFactoryFinder returns the first non-null factory it obtains.


Default behavior
The default behaviour is provided by the last two elements of the list of implementing classes, as described above:

  • org.apache.axis.configuration.EngineConfigurationFactoryServlet
    newFactory(obj) is called. If obj instanceof javax.servlet.ServletContext is true, then an instance of this class is returned.

    The default Servlet factory is expected to function as a server (as a client it will incorrectly attempt to load the WSDD file client-config.wsdd from the current working directory!).

    The default Servlet factory will open the Web Application resource /WEB-INF/server-config.wsdd (The name of this file may be changed using the system property axis.ServerConfigFile):

    • If it exists as an accessible file (i.e. not in a JAR/WAR file), then it opens it as a file. This allows changes to be saved, if changes are allowed & made using the Admin tools.

    • If it does not exist as a file, then an attempt is made to access it as a resource stream (getResourceAsStream), which works for JAR/WAR file contents.

    • If the resource is simply not available, an attempt is made to create it as a file.

    • If all above attempts fail, a final attempt is made to access org.apache.axis.server.server-config.wsdd as a data stream.


  • org.apache.axis.configuration.EngineConfigurationFactoryDefault
    newFactory(obj) is called. If obj is null then an instance of this class is returned. A non-null obj is presumed to require a non-default factory.

    The default factory will load the WSDD files client-config.wsdd or server-config.wsdd, as appropriate, from the current working directory. The names of these files may be changed using the system properties axis.ClientConfigFile and axis.ServerConfigFile, respectively.


Example, In some start up method(): properties.put("axis.EngineConfigFactory", "");

public class CustomFactory implements EngineConfigurationFactory {

    public EngineConfiguration getClientEngineConfig();

    public EngineConfiguration getServerEngineConfig();

    public static EngineConfigurationFactory newFactory(Object param);

2.2.2 WSDD

The server is configured (by default) by values in the server-config.wsdd file, though a dedicated Axis user can write their own configuration handler, and so store configuration data in an LDAP server, database, remote web service, etc. Consult the source on details as to how to do that. You can also add options to the web.xml file and have them picked up automatically. We don't encourage that as it is nice to keep configuration stuff in one place.

The internal data model used by Axis is based on an Axis specific data model: Web Services Deployment Descriptor (WSDD). Axis initially obtains the WSDD information for a service from an instance of org.apache.axis.EngineConfiguration.

WSDD Configuration: Configuration based on wsdd, but not server-config.wsdd file, it can be dynamic/further configured by Admin.deploy()

2.2.3 WSDL2Java

This tool takes a description of a web service written in WSDL and emits Java artefacts used to access the web service.

There are three layers inside the tool:

  • framework: SymbolTable, Emitter, WriterFactory

  • WSDL2Java plugin to the framework: WSDL2Java (the main), JavaWriterFactory, and all the WSDL-relative writers: JavaPortTypeWriter, JavaBindingWriter, etc.

  • The actual WSDL2Java emitters, one for each file generated: JavaInterfaceWriter, JavaStubWriter, etc.

  • So: public class WSDL2Java extends org.apache.axis.wsdl.WSDL2Java{
            public WSDL2Java() {
                getParser().setFactory(new CustomizedJavaGeneratorFactory(getParser()));

-T, --typeMappingVersion:

indicate 1.1 or 1.2. The default is 1.1 (SOAP 1.1 JAX-RPC compliant. 1.2 indicates SOAP 1.1 encoded.)

-W, --noWrapped

This turns off the special treatment of what is called "wrapped" document/literal style operations.  By default, WSDL2Java will recognize the following conditions:

  • If an input message has is a single part.

  • The part is an element.

  • The element has the same name as the operation

  • The element's complex type has no attributes