第一范文网 - 专业文章范例文档资料分享平台

axis2 WebService 开发指南

来源:用户分享 时间:2025/5/28 20:56:16 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

40

Axis WebService 技术指南

}

public void cleanup() { }

public void flowComplete(MessageContext ctx) {

System.out.println(\); }

public HandlerDescription getHandlerDesc() {

System.out.println(\); }

public Parameter getParameter(String name) {

System.out.println(\); }

public void init(HandlerDescription handlerDescription) { }

public InvocationResponse invoke(MessageContext ctx) throws }

System.out.println(ctx.getEnvelope().toString()); return InvocationResponse.CONTINUE;

System.out.println(\); return null; return null;

System.out.println(ctx.getEnvelope().toString()); System.out.println(\);

AxisFault {

编写module.xml文件 欢迎转载 请保留原文作者信息 不得未经作者允许用于商业用途

41

Axis WebService 技术指南

编写services.xml文件

使用CustomModule SimpleWebService模块

com.hoo.module.SimpleWebService

mep=\

class=\ /> mep=\

class=\

ver\ />

在[tomcat_home]\\webapps\\axis2\\WEB-INF\\conf中axis2.xml文件中加入内容,在所有的标签中加入

打包发布module,在c盘建立CustomModuleService,然后将CustomModule.class和CustomHandler.class以及类路径目录复制到该目录。然后将module.xml文件放到META-INF(没有新建)目录。

运行jar命令:jar cvf custom-module.mar .

欢迎转载 请保留原文作者信息 不得未经作者允许用于商业用途

42

Axis WebService 技术指南

将生成的custom-module.mar文件粘贴到[tomcat_home] \\webapps\\axis2\\WEB-INF\\modules目录中

发布WebService,建立目录simpleWebService,将SimpleWebService.xml和类路径复制到该目录下,将services.xml复制到META-INF目录。 运行jar命令:jar cvf simple-service.aar . 将生成的simple-service.aar文件复制到[tomcat_home] \\webapps\\axis2\\WEB-INF\\services目录下 然后重启tomcat服务。 客户端访问WebService代码

package com.hoo.service;

import javax.xml.namespace.QName; import org.apache.axis2.AxisFault;

import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.client.Options;

import org.apache.axis2.rpc.client.RPCServiceClient; /**

* function:访问SimpleWebService * @author hoojo

* @createDate 2011-3-15 上午07:26:08 * @file SimpleWebServiceClient.java * @package com.hoo.service * @project Axis2WebService

* @blog http://blog.csdn.net/IBM_hoojo * @email hoojo_@126.com * @version 1.0 */

public class SimpleWebServiceClient {

public static void main(String[] args) throws AxisFault {

String target =

RPCServiceClient client = new RPCServiceClient(); Options options = client.getOptions(); options.setManageSession(true);

EndpointReference epr = new EndpointReference(target); options.setTo(epr);

QName qname = new QName(\,

Object[] result = client.invokeBlocking(qname, new Object[] \;

\);

{ null }, new Class[] { int.class });

欢迎转载 请保留原文作者信息 不得未经作者允许用于商业用途

43

Axis WebService 技术指南

} } System.out.println(result[0]);

九、 使用SoapMonitar监视WebService的请求和响应信息

使用soapmonitar可以监视到请求和响应的WebService的基本信息,可以讲响应在控制台的信息显示在applet控件上。 步骤如下:

1、 部署相关的applet和servlet

Axis2有自带的monitor模块,这里就不需要单独安装。在[tomcat_home]\\webapps\\axis2\\WEB-INF\\lib目录中,找到axis2-soapmonitor-servlet-1.5.3.jar这个文件,将这个文件解压后,将里面的servlet的class文件放到[tomcat_home]\\webapps\\axis2\\WEB-INF\\classes目录下。将applet的class放到[tomcat_home]\\webapps\\axis2这个目录下即可。

2、 配置Servlet,这里配置的Servlet就包含上一步复制的servlet-class

在web.xml中增加如下配置 SOAPMonitorService /SOAPMonitor SOAPMonitorService org.apache.axis2.soapmonitor.servlet.SOAP SOAPMonitorPort 5001 MonitorService 1

3、 在要监视的WebService的services.xml文件中关联soapmonitor,

services.xml配置文件如下:

使用soapmonitor SimpleWebService模块 com.hoo.module.SimpleWebService 欢迎转载 请保留原文作者信息 不得未经作者允许用于商业用途

44

Axis WebService 技术指南

mep=\ class=\ceiver\ /> 将上次的WebService关联soapmonitor这个module,然后重新打包aar发布。 4、 请求http://localhost:8080/axis2/SOAPMonitor

可以看到Java的Applet,界面如下:

然后运行请求执行CustomModuleService这个service的时候,你就可一看到上面出现xml的内容。上面的内容是和控制台的同步输出的。

欢迎转载 请保留原文作者信息 不得未经作者允许用于商业用途

搜索更多关于: axis2 WebService 开发指南 的文档
axis2 WebService 开发指南.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c0pq1q8e53z1x2cx44ea3_9.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top