- 浏览: 365033 次
- 性别:
- 来自: 西安
文章分类
最新评论
-
jiangli19192:
...
自己写的一个启动JBoss服务器的bat批处理 -
56553655:
最好这样:java -Xms3700M -Xmx3700M - ...
测试本机JVM支持的最大内存 -
lizhiy05:
学习一哈……
Web Services体系结构及相关概念 -
ghy200692162:
System.out.println("开始注册Js ...
基于OSGi的JSF Web组件开发问题求解 -
xiao888lin:
你的头像看起来很像我们宿舍老四。。。
测试本机JVM支持的最大内存
构建一个新的Web Services服务,会有很多种不同的方法,你即可以用pojo结合rpc模式来写,也可以用axis2自己的axiom api从底层写,也可以从wsdl生成相应框架,然后填写相应逻辑。
对于wsdl生成框架代码这种形式,又有不同的数据绑定可以使用。axis2 1.1 可以使用adb(axis2自己的data binding)、xmlbeans、jibx、jaxme、jaxbri。其中常用的还是前两种,axis2官方是极力推荐自己的data binding的,因为速度快,架构相对简单,而且有一些独有的特性。xmlbeans,是对模式支持最好的data binding,一些特别复杂的模式只能在xmlbeans下才能正确生成框架代码。其他几种代码wsdl2java目前都不是支持得很好,都还在实验改进阶段。
面对这么多数据绑定模式,很多人都无从选择。官方maillist上也有好多人问该用哪个。查了一些资料,据说,adb很好用,而且速度快,如果只是简单的模式,那么使用这种数据绑定就可以了。xmlbeans的强力模式支持,可以支持足够负责的模式,但是速度上也只是比adb低5%左右。
axis2的wsdl2java工具对于adb以及xmlbeans支持都已经很好了,可以直接从wsdl2java生成相应的绑定类
Axis2 还提供自己的简单数据绑定框架,称为 Axis2 Data Binding (ADB)。这就允许用户下载 Axis2 并使用它,而不用太多考虑数据绑定框架。由于 ADB 和 Axis2 内部元素之间实现了紧密的集成,可以预见,与其他框架相比,此框架的性能和生成代码维护方面都更具优势。
为了充分利用资源,我们用上一个有关AXIOM专题的例子中生成的WSDL文件来为这个例子服务
1.生成ADB服务框架。使用的WSDL文件如下:
- <wsdl:definitions xmlns:axis2="http://service.util.danlley.org" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
- xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
- xmlns:ns="http://service.util.danlley.org/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- targetNamespace="http://service.util.danlley.org">
- <wsdl:types>
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified"
- targetNamespace="http://service.util.danlley.org/xsd">
- <xs:element name="getHelloMessageFault">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="getHelloMessageFault" type="xs:anyType" />
- xs:sequence>
- xs:complexType>
- xs:element>
- <xs:element name="getHelloMessage">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="element" nillable="true" type="xs:anyType" />
- xs:sequence>
- xs:complexType>
- xs:element>
- <xs:element name="getHelloMessageResponse">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="return" nillable="true" type="xs:anyType" />
- xs:sequence>
- xs:complexType>
- xs:element>
- <xs:element name="getMoreMessageFault">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="getMoreMessageFault" type="xs:anyType" />
- xs:sequence>
- xs:complexType>
- xs:element>
- <xs:element name="getMoreMessage">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="element" nillable="true" type="xs:anyType" />
- xs:sequence>
- xs:complexType>
- xs:element>
- <xs:element name="getMoreMessageResponse">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="return" nillable="true" type="xs:anyType" />
- xs:sequence>
- xs:complexType>
- xs:element>
- xs:schema>
- wsdl:types>
- <wsdl:message name="getHelloMessageMessage">
- <wsdl:part name="part1" element="ns:getHelloMessage" />
- wsdl:message>
- <wsdl:message name="getHelloMessageResponseMessage">
- <wsdl:part name="part1" element="ns:getHelloMessageResponse" />
- wsdl:message>
- <wsdl:message name="getHelloMessageFault">
- <wsdl:part name="part1" element="ns:getHelloMessageFault" />
- wsdl:message>
- <wsdl:message name="getMoreMessageMessage">
- <wsdl:part name="part1" element="ns:getMoreMessage" />
- wsdl:message>
- <wsdl:message name="getMoreMessageResponseMessage">
- <wsdl:part name="part1" element="ns:getMoreMessageResponse" />
- wsdl:message>
- <wsdl:message name="getMoreMessageFault">
- <wsdl:part name="part1" element="ns:getMoreMessageFault" />
- wsdl:message>
- <wsdl:portType name="HelloWorldAxiomPortType">
- <wsdl:operation name="getHelloMessage">
- <wsdl:input message="axis2:getHelloMessageMessage" />
- <wsdl:output message="axis2:getHelloMessageResponseMessage" />
- <wsdl:fault message="axis2:getHelloMessageFault" name="getHelloMessageFault" />
- wsdl:operation>
- <wsdl:operation name="getMoreMessage">
- <wsdl:input message="axis2:getMoreMessageMessage" />
- <wsdl:output message="axis2:getMoreMessageResponseMessage" />
- <wsdl:fault message="axis2:getMoreMessageFault" name="getMoreMessageFault" />
- wsdl:operation>
- wsdl:portType>
- <wsdl:binding name="HelloWorldAxiomSOAP11Binding" type="axis2:HelloWorldAxiomPortType">
- <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="getHelloMessage">
- <soap:operation soapAction="urn:getHelloMessage" style="document" />
- <wsdl:input>
- <soap:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:input>
- <wsdl:output>
- <soap:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:output>
- <wsdl:fault name="getHelloMessageFault">
- <soap:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:fault>
- wsdl:operation>
- <wsdl:operation name="getMoreMessage">
- <soap:operation soapAction="urn:getMoreMessage" style="document" />
- <wsdl:input>
- <soap:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:input>
- <wsdl:output>
- <soap:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:output>
- <wsdl:fault name="getMoreMessageFault">
- <soap:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:fault>
- wsdl:operation>
- wsdl:binding>
- <wsdl:binding name="HelloWorldAxiomSOAP12Binding" type="axis2:HelloWorldAxiomPortType">
- <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="getHelloMessage">
- <soap12:operation soapAction="urn:getHelloMessage" style="document" />
- <wsdl:input>
- <soap12:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:input>
- <wsdl:output>
- <soap12:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:output>
- <wsdl:fault name="getHelloMessageFault">
- <soap12:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:fault>
- wsdl:operation>
- <wsdl:operation name="getMoreMessage">
- <soap12:operation soapAction="urn:getMoreMessage" style="document" />
- <wsdl:input>
- <soap12:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:input>
- <wsdl:output>
- <soap12:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:output>
- <wsdl:fault name="getMoreMessageFault">
- <soap12:body use="literal" namespace="http://service.util.danlley.org" />
- wsdl:fault>
- wsdl:operation>
- wsdl:binding>
- <wsdl:service name="HelloWorldAxiom">
- <wsdl:port name="HelloWorldAxiomSOAP11port" binding="axis2:HelloWorldAxiomSOAP11Binding">
- <soap:address location="http://localhost:8080/axis2/services/HelloWorldAxiom" />
- wsdl:port>
- <wsdl:port name="HelloWorldAxiomSOAP12port" binding="axis2:HelloWorldAxiomSOAP12Binding">
- <soap12:address location="http://localhost:8080/axis2/services/HelloWorldAxiom" />
- wsdl:port>
- wsdl:service>
- wsdl:definitions>
2.生成工程框架
运行命令如下:WSDL2Java -uri resources/META-INF/HelloWorldAxiom.wsdl -p org.danlley.service.adb -d adb -s -ss -sd -ssi -o build/service
如果得到以下结果则说明执行成功:
--------------------------------------------------------------------------------
D:\eclipse\workspace\axis2adblab>WSDL2Java -uri resources/META-INF/HelloWorldAxi
om.wsdl -p org.danlley.service.adb -d adb -s -ss -sd -ssi -o build/service
Using AXIS2_HOME: D:\axis2-1.1.1
Using JAVA_HOME: C:\Program Files\Java\jdk1.5.0_06
D:\eclipse\workspace\axis2adblab>
--------------------------------------------------------------------------------
执行成功后在工程中出现的路径如下:
--------------------------------------------------------------------------------
./build/service/build.xml
./build/service/resources/HelloWorldAxiom.wsdl
services.xml
./build/service/src/org/danlley/service/adb/GetHelloMessageFaultException.java
GetMoreMessageFaultException.java
HelloWorldAxiomMessageReceiverInOut.java
HelloWorldAxiomSkeleton.java
HelloWorldAxiomSkeletonInterface.java
./build/service/src/org/danlley/util/service/xsd/ExtensionMapper.java
GetHelloMessage.java
GetHelloMessageFault.java
GetHelloMessageResponse.java
GetMoreMessage.java
GetMoreMessageFault.java
GetMoreMessageResponse.java
--------------------------------------------------------------------------------
3.分析框架结构
Axis·2的服务确实够周到的,不仅仅给我们把整个服务的框架都搭建好了,而且,还给我们顺便连编译工程所需用的Ant脚本都生成好了。真是不得不让人感叹一句"Apache办事,我放心!"呵呵呵。
让我们先大体看看生成的这些Java代码的作用,GetHelloMessageFaultException和GetMoreMessageFaultException是用来做异常处理的。关于这个话题我以纪在以前的专题中已经有过提及(也就是跟Fault相关的话题)。
说到Fault就不得不再提提SOAP 处理模型,Axis2 体系结构定义了两个管道(或流),分别称为 InPipe (InFlow) 和 OutPipe (OutFlow),用于处理服务器端的请求消息和响应消息。在客户端,这两个管道是反向的——换句话说,SOAP 请求消息流经 OutPipe,而响应消息流经 InPipe。管道或流包含一系列分为阶段的处理程序。除预先定义的阶段和处理程序集外,用户还可以在操作级别、服务级别或全局级别配置用户阶段和相关处理程序。处理程序充当 SOAP 消息的拦截器,可以处理 SOAP 消息的 Header 或 Body。InPipe 是通过以下阶段进行配置的:
--------------------------------------------------------------------------------
TransportIn
PreDispatch
Dispatch
PostDispatch
PolicyDetermination
User phases
Message validation
--------------------------------------------------------------------------------
请求消息在通过 Inpipe 中配置的所有阶段后,到达 MessageReceiver,然后由 MessageReceiver 调用实际服务实现。服务器的 OutPipe 包含以下阶段:
--------------------------------------------------------------------------------
Message initialization
Policy determination
User phases
MessageOut
--------------------------------------------------------------------------------
用户配置的阶段位于这两个管道的用户阶段(User phases) 部分。如果在执行这些管道的过程中发生错误,则这些错误将通过 InFaultPipe 或 OutFaultPipe 管道。收到 Fault 消息后,在客户端调用 InFaultPipe;如果某个调用导致将错误发送到客户端,则在服务器端调用 OutFaultPipe。用户可以将处理程序添加到预先定义的阶段,并且按照这些处理程序运行的顺序进行配置。
那么既然ADB pattern为我们提供了GetHelloMessageFaultException、GetMoreMessageFaultException、GetHelloMessageFault和GetMoreMessageFault类。那也就意味着我们可以对这些类进行扩充,以满足我们在实际当中的应用需求。由于我们Axiom的专题中举例时,两个实例均采用了in-Out模式,因此通过此工程的WSDL生成的ADB框架也就只有HelloWorldAxiomMessageReceiverInOut类来处理In-Out模式。GetHelloMessage和GetMoreMessage用来对接口HelloWorldAxiomSkeletonInterface的收取的数据进行封装,而GetHelloMessageResponse和GetMoreMessageResponse类则用于封装由HelloWorldAxiomSkeleton类处理后的结果。也就是说,真正的服务提供者就是HelloWorldAxiomSkeleton类。现在思路已经整理清楚,ADB生成的框架也基本上相当清楚了。那么剩下就是为我们新生成的框架动点小外科手术的时候了。
4.构建工程
根据我个人喜好,我的工程目录结构整理后如下:
--------------------------------------------------------------------------------
./build.xml
./resources/HelloWorldAxiom.wsdl
services.xml
./src/main/java/org/danlley/service/adb/GetHelloMessageFaultException.java
GetMoreMessageFaultException.java
HelloWorldAxiomMessageReceiverInOut.java
HelloWorldAxiomSkeleton.java
HelloWorldAxiomSkeletonInterface.java
./src/main/java/org/danlley/util/service/xsd/ExtensionMapper.java
GetHelloMessage.java
GetHelloMessageFault.java
GetHelloMessageResponse.java
GetMoreMessage.java
GetMoreMessageFault.java
GetMoreMessageResponse.java
--------------------------------------------------------------------------------
工程目录改变也就意味着我们需要修改Ant脚本,修改后的脚步如下:
评论
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:axis2="http://service.util.danlley.org" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns="http://service.util.danlley.org/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.util.danlley.org/xsd"> <xs:element name="getHelloMessageFault"> <xs:complexType> <xs:sequence> <xs:element name="getHelloMessageFault" type="xs:anyType" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getHelloMessage"> <xs:complexType> <xs:sequence> <xs:element name="element" nillable="true" type="xs:anyType" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getHelloMessageResponse"> <xs:complexType> <xs:sequence> <xs:element name="return" nillable="true" type="xs:anyType" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getMoreMessageFault"> <xs:complexType> <xs:sequence> <xs:element name="getMoreMessageFault" type="xs:anyType" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getMoreMessage"> <xs:complexType> <xs:sequence> <xs:element name="element" nillable="true" type="xs:anyType" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="getMoreMessageResponse"> <xs:complexType> <xs:sequence> <xs:element name="return" nillable="true" type="xs:anyType" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
这个是编写客户端必不可少的一个信息了。
6.生成客户端框架。
执行以下命令:
--------------------------------------------------------------------------------
WSDL2Java -uri resources/META-INF/HelloWorldAxiom.wsdl -p org.danlley.testcase.client -d adb -s -o build/client
--------------------------------------------------------------------------------
得到以下结果,那么说明客户端运行框架已经生成
--------------------------------------------------------------------------------
D:\eclipse\workspace\axis2adblab>WSDL2Java -uri resources/META-INF/HelloWorldAxi
om.wsdl -p org.danlley.testcase.client -d adb -s -o build/client
Using AXIS2_HOME: D:\axis2-1.1.1
Using JAVA_HOME: C:\Program Files\Java\jdk1.5.0_06
D:\eclipse\workspace\axis2adblab>
--------------------------------------------------------------------------------
根据我们的定义,该客户端框架在build/client目录下。将生成的客户端支持框架整理到我们的客户端程序存放路径下:src/test/java
目录结构如下:
--------------------------------------------------------------------------------
./src/test/java/org/danlley/testcase/client/GetHelloMessageFaultException.java
GetMoreMessageFaultException.java
HelloWorldAxiomStub.java
--------------------------------------------------------------------------------
在此目录下定义一个 ADBClient.java,也就是我们Web Services客户端。
实现ADBClient类(这里我们只实现了对getHelloMessage的处理):
package org.danlley.testcase.client; import java.io.StringWriter; import java.rmi.RemoteException; import javax.xml.stream.XMLOutputFactory; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.Options; import org.apache.axis2.client.ServiceClient; import org.danlley.util.service.xsd.GetHelloMessage; import org.danlley.util.service.xsd.GetHelloMessageResponse; public class ADBClient{ private static EndpointReference targetEPR=new EndpointReference("http://localhost:8080/axis2/services/HelloWorldAxiom"); public static void main(String[] args){ try{ getHelloMessage("Hi, Danlley !"); System.out.println("END<-----------------"); }catch(Exception e){ e.printStackTrace(); } } public static void getHelloMessage(String msg){ try{ HelloWorldAxiomStub stub=new HelloWorldAxiomStub("http://localhost:8080/axis2/services/HelloWorldAxiom"); HelloWorldAxiomStub.GetHelloMessage helloMsg=new HelloWorldAxiomStub.GetHelloMessage(); OMElement element=getOMElement(msg); helloMsg.setElement(element); System.out.println(helloMsg.getElement().toString()); HelloWorldAxiomStub.GetHelloMessageResponse helloResponse; helloResponse=stub.getHelloMessage(helloMsg); OMElement return_val=helloResponse.get_return(); System.out.println(return_val); }catch(AxisFault e){ e.printStackTrace(); }catch(RemoteException e){ e.printStackTrace(); }catch(GetHelloMessageFaultException e){ e.printStackTrace(); } } public static OMElement getOMElement(String msg){ OMFactory fac=OMAbstractFactory.getOMFactory(); OMNamespace omNs=fac.createOMNamespace("http://service.util.danlley.org/xsd","ns1"); OMElement method=fac.createOMElement("getHelloMessage",omNs); OMElement value=fac.createOMElement("msg",omNs); value.addChild(fac.createOMText(value,msg)); method.addChild(value); return method; } }
运行客户端程序:
--------------------------------------------------------------------------------
<ns1:getHelloMessage xmlns:ns1="http://service.util.danlley.org/xsd"><ns1:msg>Hi, Danlley !</ns1:msg></ns1:getHelloMessage>
<ns:getHelloMessageResponse xmlns:ns="http://service.util.danlley.org/xsd"><ns:return>You are Perfect, Danlley!</ns:return></ns:getHelloMessageResponse>
END<-----------------
--------------------------------------------------------------------------------
那么一个基于ADB pattern的Web Services就实现了。
注:此文档在8月之前将一直处于维护状态
参考资料
http://ws.apache.org/axis2/1_2/index.html
http://blog.mllm.org/node/171
http://www-128.ibm.com/developerworks/cn/webservices/ws-webaxis1/#figure1
package org.danlley.service.adb; import org.danlley.util.service.xsd.GetHelloMessage; import org.danlley.util.service.xsd.GetHelloMessageResponse; import org.danlley.util.service.xsd.GetMoreMessage; import org.danlley.util.service.xsd.GetMoreMessageResponse; public class HelloWorldAxiomSkeleton implements HelloWorldAxiomSkeletonInterface{ public GetMoreMessageResponse getMoreMessage(GetMoreMessage param4) throws GetMoreMessageFaultException{ //Todo fill this with the necessary business logic throw new UnsupportedOperationException("Please implement "+this.getClass().getName()+"#getMoreMessage"); } public GetHelloMessageResponse getHelloMessage(GetHelloMessage param6) throws GetHelloMessageFaultException{ //Todo fill this with the necessary business logic throw new UnsupportedOperationException("Please implement "+this.getClass().getName()+"#getHelloMessage"); } }
实现HelloWorldAxiomSkeleton类:
package org.danlley.service.adb; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMException; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; import org.danlley.util.service.xsd.GetHelloMessage; import org.danlley.util.service.xsd.GetHelloMessageResponse; import org.danlley.util.service.xsd.GetMoreMessage; import org.danlley.util.service.xsd.GetMoreMessageResponse; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentFactory; import org.dom4j.DocumentHelper; public class HelloWorldAxiomSkeleton implements HelloWorldAxiomSkeletonInterface{ public GetMoreMessageResponse getMoreMessage(GetMoreMessage param4) throws GetMoreMessageFaultException{ try{ OMElement element=param4.getElement(); element.build(); element.detach(); DocumentFactory dom=new DocumentFactory(); dom.createDocument(element.toString()); System.out.println(element.toString()); Document doc=DocumentHelper.parseText(element.toString()); String msg=doc.selectSingleNode("//tns:msg").getText(); String userPWD=doc.selectSingleNode("//tns:userPWD").getText(); String transactionKey=doc.selectSingleNode("//tns:transactionKey").getText(); System.out.println("\n msg="+msg+"\n userPWD="+userPWD+"\n transactionKey="+transactionKey); OMFactory fac=OMAbstractFactory.getOMFactory(); OMNamespace omNs=fac.createOMNamespace("http://service.util.danlley.org/xsd","ns"); OMElement method=fac.createOMElement("getHelloMessageResponse",omNs); OMElement value=fac.createOMElement("return",omNs); String returnText="MultiMessage for U, Danlley!"; returnText=returnText+"\n msg="+msg+"\t userPWD="+userPWD+"\t transactionKey="+transactionKey; value.addChild(fac.createOMText(value,returnText)); method.addChild(value); GetMoreMessageResponse response=new GetMoreMessageResponse(); response.set_return(method); return response; }catch(OMException e){ e.printStackTrace(); return null; }catch(DocumentException e){ e.printStackTrace(); return null; } } public GetHelloMessageResponse getHelloMessage(GetHelloMessage param6) throws GetHelloMessageFaultException{ OMElement element=param6.getElement(); element.build(); element.detach(); OMElement symbolElement=element.getFirstElement(); String helloworld=symbolElement.getText(); System.out.println("We got the messages :"+(helloworld!=null?helloworld:"No Msg!")); String returnText="You are Perfect, Danlley!"; OMFactory fac=OMAbstractFactory.getOMFactory(); OMNamespace omNs=fac.createOMNamespace("http://service.util.danlley.org/xsd","ns"); OMElement method=fac.createOMElement("getHelloMessageResponse",omNs); OMElement value=fac.createOMElement("return",omNs); value.addChild(fac.createOMText(value,returnText)); method.addChild(value); GetHelloMessageResponse response=new GetHelloMessageResponse(); response.set_return(method); return response; } }
5.发布、部署
执行ant脚本声称aar包。部署aar到tomcat目录下,在浏览器中访问:http://localhost:8080/axis2/services/HelloWorldAxiom?wsdl
就可以看到我们生成的新的WSDL。由于WSDL 文件过于繁冗,让我们看看XSD文件就已经足够了,访问地址:http://localhost:8080/axis2/services/HelloWorldAxiom?xsd 可以看到如下内容:
<project basedir="." default="jar.server"> <!--Auto generated ant build file--> <property environment="env" /> <property name="axis2.home" value="${env.AXIS2_HOME}" /> <property name="project.base.dir" value="." /> <property name="maven.class.path" value="" /> <property name="name" value="HelloWorldAxiom" /> <property name="src" value="${project.base.dir}/src/main/java" /> <property name="test" value="${project.base.dir}/src/test/java" /> <property name="build" value="${project.base.dir}/build" /> <property name="classes" value="${build}/classes" /> <property name="lib" value="${build}/lib" /> <property name="resources" value="${project.base.dir}/resources" /> <property value="" name="jars.ok" /> <path id="axis2.class.path"> <pathelement path="${java.class.path}" /> <pathelement path="${maven.class.path}" /> <fileset dir="${axis2.home}"> <include name="lib/*.jar" /> </fileset> </path> <target name="init"> <mkdir dir="${build}" /> <mkdir dir="${classes}" /> <mkdir dir="${lib}" /> <mkdir dir="${test}" /> </target> <target depends="init" name="pre.compile.test"> <!--Test the classpath for the availability of necesary classes--> <available classpathref="axis2.class.path" property="stax.available" classname="javax.xml.stream.XMLStreamReader" /> <available classpathref="axis2.class.path" property="axis2.available" classname="org.apache.axis2.engine.AxisEngine" /> <condition property="jars.ok"> <and> <isset property="stax.available" /> <isset property="axis2.available" /> </and> </condition> <!--Print out the availabilities--> <echo message="Stax Availability= ${stax.available}" /> <echo message="Axis2 Availability= ${axis2.available}" /> </target> <target depends="pre.compile.test" name="compile.src" if="jars.ok"> <javac debug="on" memoryMaximumSize="256m" memoryInitialSize="256m" fork="true" destdir="${classes}" srcdir="${src}"> <classpath refid="axis2.class.path" /> </javac> </target> <target depends="compile.src" name="compile.test" if="jars.ok"> <javac debug="on" memoryMaximumSize="256m" memoryInitialSize="256m" fork="true" destdir="${classes}"> <src path="${test}" /> <classpath refid="axis2.class.path" /> </javac> </target> <target depends="pre.compile.test" name="echo.classpath.problem" unless="jars.ok"> <echo message="The class path is not set right! Please make sure the following classes are in the classpath 1. XmlBeans 2. Stax 3. Axis2 " /> </target> <target depends="jar.server, jar.client" name="jar.all" /> <target depends="compile.src,echo.classpath.problem" name="jar.server" if="jars.ok"> <copy toDir="${classes}/META-INF" failonerror="false"> <fileset dir="${resources}"> <include name="*.xml" /> <include name="*.wsdl" /> <include name="*.xsd" /> </fileset> </copy> <jar destfile="${lib}/${name}.aar"> <fileset excludes="**/Test.class" dir="${classes}" /> </jar> </target> <target if="jars.ok" name="jar.client" depends="compile.test"> <jar destfile="${lib}/${name}-test-client.jar"> <fileset dir="${classes}"> <exclude name="**/META-INF/*.*" /> <exclude name="**/lib/*.*" /> <exclude name="**/*MessageReceiver.class" /> <exclude name="**/*Skeleton.class" /> </fileset> </jar> </target> <target if="jars.ok" name="make.repo" depends="jar.server"> <mkdir dir="${build}/repo/" /> <mkdir dir="${build}/repo/services" /> <copy file="${build}/lib/${name}.aar" toDir="${build}/repo/services/" /> </target> <target if="jars.ok" name="start.server" depends="make.repo"> <java fork="true" classname="org.apache.axis2.transport.http.SimpleHTTPServer"> <arg value="${build}/repo" /> <classpath refid="axis2.class.path" /> </java> </target> <target depends="compile.test" name="run.test" if="jars.ok"> <path id="test.class.path"> <pathelement location="${lib}/${name}-test-client.jar" /> <path refid="axis2.class.path" /> </path> <mkdir dir="${build}/test-reports/" /> <junit haltonfailure="yes" printsummary="yes"> <classpath refid="test.class.path" /> <formatter type="plain" /> <batchtest fork="yes" toDir="${build}/test-reports/"> <fileset dir="${test}"> <include name="**/*Test*.java" /> </fileset> </batchtest> </junit> </target> <target name="clean"> <delete dir="${build}" /> </target> </project>
发表评论
-
让mybatis支持管理和操作多个不同的业务数据库实例
2017-05-07 21:25 6358在微服务大行其道的今天,一个工程中同时操作多个不同的业务数 ... -
Spring Acegi鉴权管理之基础模式(BASIC)
2017-05-01 01:25 1062Acegi久负盛名,这个家伙是一个spring中广泛使用的认 ... -
Restful架构服务构建指南
2017-04-17 01:19 495REST定位为“分布式超媒体应用(Distributed H ... -
集成ibatis的spring工程升级到spring4.0实操手册
2017-04-03 21:57 3243Spring4及已经的版本放弃了对ibatis的集成支持, ... -
Docker使用之Java web应用部署
2017-03-26 13:50 3981此篇博客一部分内容 ... -
Java设计设计模式之桥接模式(Bridge)
2017-03-11 19:19 0... -
Java设计设计模式之组合模式(Composition)
2017-03-11 17:32 1031那王麻子自从做了肉夹馍生意后,真是风生水起,分店开的跟下饺 ... -
Java设计设计模式之适配器模式(Adaptor)
2017-03-05 15:29 1502我的博客自从2008年以 ... -
RBAC原理介绍及开源框架kasai使用分析
2008-08-13 16:20 10496RBAC 模型作为目前 ... -
用Maven Plug-In来构建Corba开发环境
2008-03-21 10:49 2985这两天研究Corba,总是感觉需要在Java的命令行执行“id ... -
LDAP介绍
2008-03-18 09:57 16091.1. LDAP是什么 LDAP是轻量目录访问协议,英文全称 ... -
Java与CORBA技术结合的前景展望
2008-03-13 11:09 1906随着Internet、Intranet及Extranet在全球 ... -
Drools规则引擎应用总结
2008-02-01 10:07 0package com.playphone.qc.workfl ... -
详解Axis2实现Web Services之AXIOM篇
2007-07-17 22:30 6877AXIOM——AXis 对象模型(AXis Object M ... -
详解Axis2实现Web Services之POJOs篇
2007-07-17 22:25 5271在Axis2对Web Services的众多实现方式中,POJ ... -
Web Services体系结构及相关概念
2007-07-17 22:20 3825Web Services体系结构是面向对象分析与设计(OOA ... -
Spring包结构以及各个包之间引用关系说明
2007-07-17 22:02 5120Spring 包结构说明: spring.jar 包含 ... -
从Hello World开始深入Ajax
2007-07-17 21:11 15931. 初始化XMLHttpRequest对象 ... -
在Javascript中用来获取页面焦点信息
2007-07-17 16:59 4171在Javascript中用来获取页 ... -
详解Hibernate与WebService结合使用
2007-07-17 16:58 2466以前一直在研究EJB和Struts,最近开始研究Hiber ...
相关推荐
用axis2开发web services 所需jar包
Java 中,使用axis来实现webServices 里面包含Word详细说明使用webservices的步骤, 看了就会啦, 使用webServicers里面jar ,和工具都包含在里面。。。 如果你要实现webservies的话, 不看后悔死你。。。。
用axis2开发Web Services,内容包括环境搭建,插件安装,以及用axis2开发Web Services的详细步骤及实例程序;
Chapter 1, Apache Web Services and Axis2 - Gives you an introduction to web services and the web service stack at Apache. Chapter 2, Looking inside Axis2 - Learn about Axis2 architecture and the ...
使用Java+Axis2调用Web Services 网络接口,代码中列举4个例子可以查看,有详细注释提供参考。
包括3本Axis2的书(英文),實為2本(第1本有...1.Developing Web Services with Apache CXF and Axis2, 3rd Edition 2.Packt.Publishing.Quickstart.Apache.Axis2 3.Develop Web Services With Apache Axis2 PDF格式
Extensive and detailed coverage of the enterprise ready Apache Axis2 Web Services / SOAP / WSDL engine. Attain a more flexible and extensible framework with the world class Axis2 architecture. Learn ...
基于AXIS2实现Web Service开发
axis 实现 web services java 实例 webservices 参考:http://blog.csdn.net/chinarenzhou/article/details/7609953
Apache Axis2 Web Services 2nd Edition
其中包括两种利用axis2发布WebService的程序。一种是将项目直接集成到axis2内部里面,一种是将axis2集成到已有的项目中。各有优缺点。
使用jax-ws 来发布一个webservice,客户端使用 axis2 取得webservices 的数据。一个很好的例子,有返回数组的,有返回LIST。
AXIS实现Web 服务之深入篇 webservice优秀学习资料
用axis1开发Web Services入门,包括axis1插件的安装,环境的配置以及Web Services入门程序。
也可以自行去 apache官网下载 ,另外还包含一个已经集成了axis2的web工程源码 使用的jdk1.6开发,可以直接把web工程导入到myeclipse,部署到tomcat可运行后,浏览器输入 http://localhost:端口号/Axis2Web/services/...
Axis2集成Spring发布WebServices服务
建立一个 JavaProject 命名为 ws ,将 axis2 用户库加入到 build path 中。 2). 现在开始编写要发布的 WebSevice ,在 src 中建包 briup ,建立 Hello 类如下 Package pkg.service; public class Hello { ...
一、Axis的安装 <br/>应用Axis开发Web Services,你需要安装如下软件: 1.JDK1.4.2或以上 2.http://ws.apache.org/axis/dist/1_1/下载得到 3.一个支持Servlet的服务器引擎,比如广为人知的Tomcat。...
axis开发webservices.doc
经本人测试方法ok,希望能帮助大家。网上找了很多,最终这个是成功的。