原文地址:
http://www.blogjava.net/ponzmd/articles/142045.html
说明:这部分只要是Axis1.4Doc的摘要,只截取了我不明白和感兴趣的部分。可以当作一个快速索引和入门资料来看,如有不明白可直接查看Axis1.4的发布文档。
欢迎转载,但是请注明出处,转载地址:http://www.blogjava.net/ponzmd/articles/142045.html
AXIS1.4 DOC 阅读笔记
安装介绍
作为单独WebApplication安装
- Step1:拷贝AXIS工程/webapps/axis到相应web服务器的部署目录即可
- Step2:启动web服务器.访问: http://127.0.0.1:8080/axis/ 和 http://localhost:8080/axis/happyaxis.jsp ;如不正常改正错误即可
- Step3:Test a SOAP Endpoint:http://localhost:8080/axis/services/Version?method=getVersion
- Step4:Test a JWS Endpoint http://localhost:8080/axis/EchoHeaders.jws?method=list .
集成AXIS
- 1.Add axis.jar, wsdl.jar, saaj.jar, jaxrpc.jar and the other dependent libraries to your WAR file.
- 2.Copy all the Axis Servlet declarations and mappings from axis/WEB-INF/web.xml and add them to your own web.xml
- 3.Build and deploy your webapp.
- 4.Run the Axis AdminClient against your own webapp, instead of Axis, by changing the URL you invoke it with
遗留问题(没有配置成功)
如何配置使用SOAPMonitor?
注意事项
配置Classpath一定要加入所有的Jar包,少一个都会错
用户向导
什么是AXIS
AXIS: Apache EXtensible Interaction System
AXIS包括什么?
- a SOAP engine -- a framework for constructing SOAP processors such as clients, servers, gateways
- a simple stand-alone server
- a server which plugs into servlet engines such as Tomcat
- extensive support for the Web Service Description Language (WSDL)
- emitter tooling that generates Java classes from WSDL
- some sample programs,anda tool for monitoring TCP/IP packets
部署WebService
- 方式1:JWS:将需要部署的WebService的源文件改扩展名.java为.jws,将其至于工程的根目录下面,发布即告完成。需要注意的是:要部署的文件只能使用默认包。
- 方式2:WSDD:编写WSDD文件,通过执行org.apache.axis.client.AdminClient来部署。也可以通过此类撤销已部署的WebService服务。
配置WSDD,通过org.apache.axis.client.AdminClient来部署
WSDD: Web Service Deployment Descriptor
基本配置:
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <service name="MyService" provider="java:RPC"> <parameter name="className" value="samples.userguide.example3.MyService"/> <parameter name="allowedMethods" value="*"/> </service> </deployment>
常用配置:配置JavaBean 客户端代码:
QName qn = new QName( "urn:BeanService", "Order" ); call.registerTypeMapping(Order.class, qn, new org.apache.axis.encoding.ser.BeanSerializerFactory(Order.class, qn), new org.apache.axis.encoding.ser.BeanDeserializerFactory(Order.class, qn));
WSDD文件:
<beanMapping qname="myNS:Order" xmlns:myNS="urn:BeanService" languageSpecificType="java:samples.userguide.example5.Order"/>
扩展配置:参照《Reference Material 》
访问WebService
编写服务访问客户端,并执行之(必要步骤,example3为例)
Step1:获取服务的访问地址:
String endpointURL = "http://localhost:8080/axis/services/MyService";
Step2:构建Service 和 Call对象:
Service service = new Service(); Call call = (Call) service.createCall();
Step3:确定访问目标:
call.setTargetEndpointAddress( new java.net.URL(endpointURL) ); call.setOperationName( new QName("http://example3.userguide.samples", "serviceMethod") );
Step4:(可选) 配置参数类型:
call.addParameter( "arg1", XMLType.XSD_STRING, ParameterMode.IN); call.setReturnType( org.apache.axis.encoding.XMLType.XSD_STRING );
Step5:发起访问,并获取反馈:
String ret = (String) call.invoke( new Object[] { textToSend } );
Step6:处理异常:
try {//上面那些 } catch (AxisFault fault) {et = "Error : " + fault.toString();}
通过WSDL来访问WebService(必要步骤,以Example6为例)
WSDL(Web Service Description Language):Web服务器描述语言是用XML文档来描述Web服务的标准,是Web服务的接口定义语言,由Ariba、Intel、IBM、MS等共同提出,通过WSDL,可描述Web服务的三个基本属性:
- 服务做些什么——服务所提供的操作(方法)
- 如何访问服务——和服务交互的数据格式以及必要协议
- 服务位于何处——协议相关的地址,如URL
Step1:获得WSDL文件
方式1:?WSDL http://<host>/axis/services/<service-name>?wsdl http://<host>/axis/*.jws?wsdl
方式2:JAVA2WSDL工具 % java org.apache.axis.wsdl.Java2WSDL -o wp.wsdl -l"http://localhost:8080/axis/services/WidgetPrice" -n "urn:Example6" -p"samples.userguide.example6" "urn:Example6" samples.userguide.example6.WidgetPrice
Where: -o indicates the name of the output WSDL file -l indicates the location of the service -n is the target namespace of the WSDL file -p indicates a mapping from the package to a namespace. There may be multiple mappings. the class specified contains the interface of the webservice.
Step2:通过WSDL2JAVA工具获得辅助类 % java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s -S true -N urn:Example6 samples.userguide.example6 wp.wsdl
WidgetPriceSoapBindingImpl.java : Java file containing the default server implementation of the WidgetPrice web service. You will need to modify the *SoapBindingImpl file to add your implementation WidgetPrice.java: 定义了Web服务接口 WidgetPriceService.java: 定义了用于获取Web服务接口的方法。 WidgetPriceServiceLocator.java: 定义了用于获取Web服务接口的方法。 WidgetPriceSoapBindingStub.java:Web服务客户端桩,通过该类与服务器交互。 WidgetPriceSoapBindingSkeleton.java: Server side skeleton. deploy.wsdd: Deployment descriptor undeploy.wsdd: Undeployment descriptor 这几个JAVA类帮我们处理了大部分的逻辑,我们需要的仅仅是把这些类加到我们的项目然后创建一个我们自己的类来调用它们即可
Step3:编写客户端代码: 通过***ServiceLocator构造***Service方法,通过***Service对象获得提供服务的类对象,进而调用提供服务类对象上的方法,提供服务。
工具使用
the Axis TCP Monitor :java org.apache.axis.utils.tcpmon [listenPort targetHost targetPort]
the SOAP Monitor :
WebService安全
常见攻击方式
Denial of Service to a server
Interception and manipulation of messages
Forged client requests or Forged server responses
attempts to read the server file system/database
Attempts to write to the server file system/database
判断来访者
AXIS不支持判断请求服务的是谁.可以使用 xmlsec.jar来支援它
AXIS推荐使用HTTPS来加强这种安全性
Axis 不支持HTTP1.1 Digest Authentication,需要the HttpClient libraries配合工作
可考虑的安全措施
Disguise:不要让人知道你运行了AXIS
Cut down the build: 仅仅保留你需要的部分
Rename things:换掉默认的名称,如The AxisServlet, the AdminService, even happyaxis.jsp
Stop AxisServlet listing services :axis.enableListQuery =false
Keep stack traces out of the responses :axis.development.system =true
Edit the .wsdd configuration file, as described in the reference, to return a WSDL resource which is simply an empty <wsdl/> tag.
Servlets2.3: use filters for extra authentication
Log things
Run Axis with reduced Java rights
Run the web server with reduced rights
Monitor Load
Consider 'tripwire' and 'honeypot' endpoints(没明白)
AXIS ANT Task
在axis-ant.jar中定义
主要任务
Creating Java files from WSDL
Creating WSDL files from Java
Talking to the admin service
具体配置看文档
《Reference Material》
其中注意包括了WSDL2JAVA,JAVA2WSDL的具体使用,以及WSDD的配置信息等技术细节