1)介绍:
Axis2是一个Web Services/SOAP/WSDL引擎,被广泛的成功的应用Axis的SOAP栈,它的 Web services引擎实现了java语言和c语言。
2)特性和优点标准:
1、speed
使用它自己的对象模型和StAX数据传输流(基于xml文件传输)相比于更早的版本的axis是快速的。
2、Low memory foot print
3、AXIOM
这个是axis自己的对象模型(Axis Object model),优点是对消息有很高的扩展,高性能和开发方便。
4、Hot Deployment
热部署
5、Asynchronous Web services
异步的web service
6、MEP Support
AXIS2现在可以灵活地支持消息交换模式(WSDL 2.0)
7、Flexibility
axis2架构让开发者完成独立的给引擎(自定义报头,系统管理和其他你能够想到的)插入扩展。
8、Stability
定义接口集相对于axis的支持稳定
9、Component-oriented Deployment
面向构建的部署
10、Transport Framework
有对于整合和数据传输是干净和简单抽象(也就是可以发送和鉴定SOAP包括的多种协议,比如SMTP,FTP,消息源中间构件),这个传输框架引擎的核心是完全独立的。
11、WSDL support
Axis2支持Web service描述语言版本1.1和2.0(普及以下WSDL有历史原因每个版本的兼容性没有那么好,所以这儿指出支持1.1和2.0),允许从远程服务接收构建stubs,自动到处部署的services的可读描述(WSDL)
12、Composition and Extensibility
模块和阶段提高对可组合性和可扩展性。modules支持可组组合性和能支持新的WS-*。modules不支持热部署
3)wsdl2java.sh 命令:
1、手册:
-o <path> 为生成的代码创建一个特别的文件.
-a 生成异步风格的代码 (Default: off).
-s 生成同步风格的代码 (Default: off). Takes precedence over -a.
-p <pkg1> 在生成的代码里面插入包
-l <language> 验证语言是java语言还是c语言 (Default: java).
-t 为生成的代码生成一个测试.
-ss 生成服务代码(i.e. skeletons) (Default: off).
-sd 生成服务描述(i.e. services.xml). (Default: off). Valid with -ss.
-d <databinding> Valid databinding(s) are adb, xmlbeans, jibx and jaxbri (Default: adb).
-g Generates all the classes. It generates clases for both client side and server side including derived classes of the schema.
-pn <port_name> 当 wsdl中有多个端口的时候,这个指定一个特别的端口.
-sn <service_name> 当wsdl中有多个服务的时候,这个指定一个特别的服务.
-u 解压databinding classes
-r <path> Specify a repository against which code is generated.
-ns2p ns1=pkg1,ns2=pkg2 Specify a custom package name for each namespace specified in the wsdls schema.
-ssi 为服务的实现生成一个接口 (Default: off).
-wv <version> WSDL Version. Valid Options : 2, 2.0, 1.1
-S <path> Specify a directory path for generated source
-R <path> Specify a directory path for generated resources
-em <file path> Specify an external mapping file
-f Flattens the generated files
-uw Switch on un-wrapping.
-xsdconfig <file path> Use XMLBeans .xsdconfig file. Valid only with -d xmlbeans.
-ap 为所有的端口生成代码
-or 覆盖存在的类
-b 生成axis1.*向后兼容的代码.
-sp Suppress namespace prefixes (Optimzation that reduces size of soap request/response)
-E<key> <value> 特定的额外配置选项 to certain databindings. Examples:
-Ebindingfile <path> (for jibx) - specify the file path for the binding file
-Etypesystemname <my_type_system_name> (for xmlbeans) - override the randomly generated type system name
-Ejavaversion 1.5 (for xmlbeans) - generates Java 1.5 code (typed lists instead of arrays)
-Emp <package name> (for ADB) - extension mapper package name
-Eosv (for ADB) - turn off strict validation.
-Ewdc (for xmlbeans) - Generate code with a dummy schema. if someone use this option
they have to generate the xmlbeans code seperately with the scomp command comes with the
xmlbeans distribution and replace the Axis2 generated classes with correct classes
-EbindingFileName <path> (for jaxbri) - specify the file path for the episode file
-Eiu (for ADB) - Ignore Unexpected elements instead of throwing ADBException
--noBuildXML Dont generate the build.xml in the output directory
--noWSDL Dont generate WSDLs in the resources directory
--noMessageReceiver Dont generate a MessageReceiver in the generated sources
--http-proxy-host <host> Proxy host address if you are behind a firewall
--http-proxy-port <port> Proxy port address if you are behind a firewall
-http-proxy-user <user name> Proxy user name for basic authentication if you are behind a firewall
-http-proxy-password <password> Proxy password for basic authentication if you are behind a firewall
-ep <package-name-list> Exclude packages - these packages are deleted after code generation
-sin <interface-name> Skeleton interface name - used to specify a name for skeleton interface other than the default one
-scn <class-name> Skeleton class name - used to specify a name for skeleton class other than the default one
-oaa <override-absolute-address> -change the absolute http addresses to local file addresses generated by wsdl2java tool
-ebc <exception-base-class> -generated Exceptions are inherited from this exception rather than the java.lang.Exception class
-uon <use-operation-name> -by default the first letter of the generated method name changeed to lowercase. This option stops that and make it same as operation name
-D<Key>=<Value> -Java system properties
2、simple:
<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true" classpathref="axis2.classpath">
<arg line="-uri ${wsdl.uri}"/>
<arg line="-s"/>
<arg line="-ss"/>
<arg line="-sd"/>
<arg line="-ssi"/>
<arg line="-ap"/>
<arg line="-ns2p http://quickstart.samples/xsd=samples.quickstart.service.adb.xsd"/>
<arg line="-l java"/>
<arg line="-p samples.quickstart.service.adb"/>
<arg line="-d adb"/>
<arg line="-o ${build.dir}/service"/>
</java>
<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true" classpathref="axis2.classpath">
<arg line="-uri ${wsdl.uri}"/>
<arg line="-s"/>
<arg line="-ss"/>
<arg line="-uw"/>
<arg line="-sd"/>
<arg line="-ssi"/>
<arg line="-ap"/>
<arg line="-ns2p http://quickstart.samples/xsd=samples.quickstart.service.jibx.xsd"/>
<arg line="-l java"/>
<arg line="-p samples.quickstart.service.jibx"/>
<arg line="-d jibx"/>
<arg line="-o ${build.dir}/service"/>
</java>
<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
<arg line="-uri ${wsdl.uri}"/>
<arg line="-ss"/>
<arg line="-sd"/>
<arg line="-o ${target}"/> <!-- Output directory in which to generate files --> <!-- NB it generates to the src folder under this directory!! -->
<classpath>
<fileset dir="..\..\lib">
<include name="*.jar"/>
</fileset>
</classpath>
</java>
<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
<arg line="-uri ${wsdl.uri}"/>
<arg line="-u"/>
<arg line="-o ${target}"/>
<classpath>
<fileset dir="${env.AXIS2_HOME}\lib">
<include name="*.jar"/>
</fileset>
</classpath>
</java>
<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true" classpathref="axis2.classpath">
<arg line="-uri ${wsdl.uri}"/>
<arg line="-ss"/>
<arg line="-sd"/>
<arg line="-ap"/>
<arg line="-p samples.databinding"/>
<arg line="-d none"/>
<arg line="-o ${service.target}"/>
</java>
<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true" classpathref="axis2.classpath">
<arg line="-uri ${wsdl.uri}"/>
<arg line="-u"/>
<arg line="-ap"/>
<arg line="-p samples.databinding"/>
<arg line="-d none"/>
<arg line="-t"/>
<arg line="-o ${client.target}"/>
</java>
4)java2wsdl.sh命令:(很少使用)
1、手册:
-o <output location> 输出目录
-of <output file name> 给生成的WSDL指定名称
-sn <service name> service name
-l <one or more soap addresses> location URIs, comma-delimited
-cp <class path uri> list of classpath entries - (urls)
-tn <target namespace> target namespace for service
-tp <target namespace prefix> target namespace prefix for service
-stn <schema target namespace> target namespace for schema
-stp <schema target namespace prefix> target namespace prefix for schema
-st <binding style> style for the WSDL
-u <binding use> use for the WSDL
-nsg <class name> fully qualified name of a class that implements NamespaceGenerator
-sg <class name> fully qualified name of a class that implements SchemaGenerator
-p2n [<java package>,<namespace] [<java package>,<namespace]...
java package to namespace mapping for argument and return types
-p2n [all, <namespace>] to assign all types to a single namespace
-efd <qualified/unqualified> setting for elementFormDefault (defaults to qualified)
-afd <qualified/unqualified> setting for attributeFormDefault (defaults to qualified)
-xc class1 -xc class2... extra class(es) for which schematype must be generated.
-wv <1.1/2.0> wsdl version - defaults to 1.1 if not specified
-dlb generate schemas conforming to doc/lit/bare style
-dne disallow nillable elements in the generated schema
-doe disallow optional elements in the generated schema
-disableSOAP11 disable binding generation for SOAP 1.1
-disableSOAP12 disable binding generation for SOAP 1.2
-disableREST disable binding generation for REST
-mpn <messagePartName> change the part name of the generated wsdl messages
-ptn <portTypeName> port Type name of the WSDL
-soap11BindingName <SOAP 1.1 name> SOAP 1.1 binding name
-soap12BindingName <SOAP 1.2 name> SOAP 1.2 binding name
-restBindingName <REST name> REST binding name
-res <requestElementSuffix> Adds a suffix to the request elemment
-dat <disallowAnonymousTypes> Creates a named complex type for the annonymous complex type
2、sample:
<taskdef name="java2wsdl"
classname="org.apache.ws.java2wsdl.Java2WSDLTask"
classpathref="axis2.classpath"/>
<java2wsdl className="samples.quickstart.service.pojo.StockQuoteService"
outputLocation="${build.dir}"
targetNamespace="http://quickstart.samples/"
schemaTargetNamespace="http://quickstart.samples/xsd">
<classpath>
<pathelement path="${axis2.classpath}"/>
<pathelement location="${build.dir}/classes"/>
</classpath>
</java2wsdl>