Axis : 远去前的备忘

本文介绍Apache Axis的集成方式及配置方法,包括如何通过servlet形式集成到Web容器、配置WebService与Java类的映射关系,以及如何通过WSDD文件进行服务配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1, 使用

 

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

    <servlet>

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

        <servlet-name>AxisServlet</servlet-name>

        <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>

    </servlet>

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

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

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

    <servlet-mapping>

        <servlet-name>AxisServlet</servlet-name>

        <url-pattern>*.jws</url-pattern>

    </servlet-mapping>

    <servlet-mapping>

        <servlet-name>AxisServlet</servlet-name>

        <url-pattern>/services/*</url-pattern>

    </servlet-mapping>

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" />

        <namespace>http://webservice.organization.nucleus</namespace>

        <typeMapping encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" qname="ns1:CategoryInfo"

                     languageSpecificType="java:nucleus.organization.webservice.CategoryInfo"

                     serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"

                     deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"

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

    </service>

 

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

JAXRPCHandler

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

  HTTPSender

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

  LocalSender

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", "com.our.ws.CustomFactory");

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() {
                super();
                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.) http://issues.apache.org/jira/browse/AXIS-2467

-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

 

[入门数据分析的第一堂课]这是一门为数据分析小白量身打造的课程,你从网络或者公众号收集到很多关于数据分析的知识,但是它们零散不成体系,所以第一堂课首要目标是为你介绍:Ø  什么是数据分析-知其然才知其所以然Ø  为什么要学数据分析-有目标才有动力Ø  数据分析的学习路线-有方向走得更快Ø  数据分析的模型-分析之道,快速形成分析思路Ø  应用案例及场景-分析之术,掌握分析方法[哪些同学适合学习这门课程]想要转行做数据分析师的,零基础亦可工作中需要数据分析技能的,例如运营、产品等对数据分析感兴趣,想要更多了解的[你的收获]n  会为你介绍数据分析的基本情况,为你展现数据分析的全貌。让你清楚知道自己该如何在数据分析地图上行走n  会为你介绍数据分析的分析方法和模型。这部分是讲数据分析的道,只有学会底层逻辑,能够在面对问题时有自己的想法,才能够下一步采取行动n  会为你介绍数据分析的数据处理和常用分析方法。这篇是讲数据分析的术,先有道,后而用术来实现你的想法,得出最终的结论。n  会为你介绍数据分析的应用。学到这里,你对数据分析已经有了初步的认识,并通过一些案例为你展现真实的应用。[专享增值服务]1:一对一答疑         关于课程问题可以通过微信直接询问老师,获得老师的一对一答疑2:转行问题解答         在转行的过程中的相关问题都可以询问老师,可获得一对一咨询机会3:打包资料分享         15本数据分析相关的电子书,一次获得终身学习
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值