- 浏览: 197360 次
- 性别:
- 来自: 河北
最新评论
-
沉默表明一切1:
楼主想问一下,怎样才能在浏览器看到这个store的内容,var ...
operamasks-ui之omGrid简单使用 -
asd001oo:
非常感谢 解决了我的问题
EasyUI-combobox-监听onblur事件 -
han0917:
mamacmm 写道你看一下xblink源码吧,它提供的方法好 ...
使用XBlink操作XML -
mamacmm:
你看一下xblink源码吧,它提供的方法好像没有这样的功能
使用XBlink操作XML -
han0917:
我想问下我使用XBlink序列化对象为xml的时候,对某字段A ...
使用XBlink操作XML
Axis2简单入门
- 博客分类:
- J2EE
1.到Apache官网下载Axis2
给你地址:http://axis.apache.org/axis2/java/core/download.cgi
2.设置环境
把下载好的Axis2放到一个你喜欢的位置,我放在了
F:\Program Files\axis2-1.5.5
然后设置环境变量:
AXIS2_HOME=F:\Program Files\axis2-1.5.5 在PATH 最后添加 ;%AXIS2_HOME%\bin
3.简单测试
%AXIS2_HOME%\bin\axis2server.bat (Windows)
执行这个脚本,会看到:
Using JAVA_HOME C:\Program Files\Java\jdk1.7.0 Using AXIS2_HOME F:\Program Files\axis2-1.5.5 [INFO] [SimpleAxisServer] Starting [INFO] [SimpleAxisServer] Using the Axis2 RepositoryF:\Program Files\axis2-1.5.5\repository [SimpleAxisServer] Using the Axis2 RepositoryF:\Program Files\axis2-1.5.5\repository [SimpleAxisServer] Using the Axis2 Configuration FileF:\Program Files\axis2-1.5.5\conf\axis2.xml [INFO] Clustering has been disabled [INFO] Deploying module: addressing-1.5.5 - file:/F:/Program Files/axis2-1.5.5/repository/modules/ad dressing-1.5.5.mar [INFO] Deploying module: metadataExchange-1.5.5 - file:/F:/Program Files/axis2-1.5.5/repository/modu les/mex-1.5.5.mar [INFO] Deploying module: mtompolicy-1.5.5 - file:/F:/Program Files/axis2-1.5.5/repository/modules/mt ompolicy-1.5.5.mar [INFO] Deploying module: ping-1.5.5 - file:/F:/Program Files/axis2-1.5.5/repository/modules/ping-1.5 .5.mar [INFO] Deploying module: script-1.5.5 - file:/F:/Program Files/axis2-1.5.5/repository/modules/script ing-1.5.5.mar [INFO] Deploying module: soapmonitor-1.5.5 - file:/F:/Program Files/axis2-1.5.5/repository/modules/s oapmonitor-1.5.5.mar [INFO] Deploying Web service: version.aar - file:/F:/Program Files/axis2-1.5.5/repository/services/v ersion.aar [INFO] [SimpleAxisServer] Started [SimpleAxisServer] Started [INFO] Listening on port 8080
在浏览器里面输入:http://localhost:8080/axis2/services/
如果看到:
Deployed servicesVersion
Available operations
- getVersion
这说明Axis2没问题
4.编译Axis2项目
首先,你应该下载了 Ant ,并且版本要大于 1.6.5 ,设置好Ant环境变量 ,然后再进行下面的操作
下面进入到 $AXIS_HOME/webapp 下
F:\Program Files\axis2-1.5.5\webapp>ant -version Apache Ant(TM) version 1.8.2 compiled on December 20 2010 F:\Program Files\axis2-1.5.5\webapp>ant create.war Buildfile: F:\Program Files\axis2-1.5.5\webapp\build.xml init: [mkdir] Created dir: F:\Program Files\axis2-1.5.5\dist [mkdir] Created dir: F:\Program Files\axis2-1.5.5\dist\temp [copy] Copying 59 files to F:\Program Files\axis2-1.5.5\dist\temp prepare.repo: [copy] Copying 9 files to F:\Program Files\axis2-1.5.5\dist\temp\WEB-INF [mkdir] Created dir: F:\Program Files\axis2-1.5.5\dist\temp\WEB-INF\conf [copy] Copying 1 file to F:\Program Files\axis2-1.5.5\dist\temp\WEB-INF\conf create.war: [war] Building war: F:\Program Files\axis2-1.5.5\dist\axis2.war [delete] Deleting directory F:\Program Files\axis2-1.5.5\dist\temp BUILD SUCCESSFUL Total time: 4 seconds F:\Program Files\axis2-1.5.5\webapp>
这样,便编译好了Axis2的项目。
5.测试Axis2项目
准备使用 Tomcat容器,所以,没有的先下载。
刚刚build好的Axis2项目应该在 AXIS2_HOME/dist 下面
把这个 axis2.war 剪切(或者复制)到tomcat下的webapp目录下,启动Tomcat(启动前把刚刚打开的Axis服务关掉,因为都用了8080端口)。
再输入下面的地址:
http://localhost:8080/axis2/axis2-web/index.jsp
如果看到这样的结果:
Welcome!
Welcome to the new generation of Axis. If you can see this page you have successfully deployed the Axis2 Web Application. However, to ensure that Axis2 is properly working, we encourage you to click on the validate link.
-
Services
View the list of all the available services deployed in this server. -
Validate
Check the system to see whether all the required libraries are in place and view the system information. -
Administration
Console for administering this Axis2 installation.
说明成功了。
点击 Services 可查看当前存在的服务。
6.编写测试服务
使用Eclipse新建一个Java项目
导入所需jar包:当然就是 %AXIS2_HOME%\lib 下面的所有jar包(为了方便)。
新建包:
mm.test.webservices.axis2userguide
在这个包下面
创建 SampleService.java
内容如下:
package mm.test.webservices.axis2userguide; import javax.xml.stream.XMLStreamException; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; public class SampleService { public OMElement sayHello(OMElement element) throws XMLStreamException { element.build(); element.detach(); String rootName = element.getLocalName(); System.out.println("Reading " + rootName + " element"); OMElement childElement = element.getFirstElement(); String personToGreet = childElement.getText(); OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace( "http://example1.org/example1", "example1"); OMElement method = fac.createOMElement("sayHelloResponse", omNs); OMElement value = fac.createOMElement("greeting", omNs); value.addChild(fac.createOMText(value, "Hello, " + personToGreet)); method.addChild(value); return method; } @SuppressWarnings("unused") private void ping() { } }
然后再到另一个地方(随意,当然,当前项目下也可以)创建一个文件夹:
J:\SampleService
这是我的。
然后,把刚才编译好的 mm.test.webservices.axis2userguide.SampleService.class
连带文件夹拷到这个目录下
再在当前目录下新建:
META-INF
在META-INF目录下新建文件:services.xml,内容如下:
<service name="UserGuideSampleService"> <description> This is a sample service created in the Axis2 User's Guide </description> <parameter name="ServiceClass"> mm.test.webservices.axis2userguide.SampleService </parameter> <operation name="sayHello"> <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> </operation> <operation name="ping"> <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/> </operation> </service>
还是在J:\SampleService文件夹下,打开cmd窗口,输入:
J:\SampleService>jar cvf SampleService.aar ./* 标明清单(manifest) 忽略项 META-INF/ 增加:META-INF/services.xml(读入= 549) (写出= 243)(压缩了 55%) 增加:mm/(读入= 0) (写出= 0)(存储了 0%) 增加:mm/test/(读入= 0) (写出= 0)(存储了 0%) 增加:mm/test/webservices/(读入= 0) (写出= 0)(存储了 0%) 增加:mm/test/webservices/axis2userguide/(读入= 0) (写出= 0)(存储了 0%) 增加:mm/test/webservices/axis2userguide/SampleService.class(读入= 2232) (写出= 1074)(压缩了 51%) J:\SampleService>
这样,就会在 J:\SampleService 目录下生成一个 SampleService.aar 包。
7.部署测试服务
第1种:使用管理控制台部署
打开管理控制台:http://localhost:8080/axis2/axis2-admin/
输入用户名密码:admin/axis2
选择第一项 : Upload Service
找到刚才生成的 SampleService.aar 直接部署吧(点击 浏览 --> upload)
第2种:手工拷贝到对应地址
这个没得说,就把 SampleService.aar 直接拷贝到
%TOMCAT_HOME%\webapps\axis2\WEB-INF\services
这个目录下面就可以了。
8.查看是否部署成功
http://localhost:8080/axis2/services/listServices
打开后,可以看到:
UserGuideSampleService
多出了这么一个服务,说明部署成功。
9.编写客户端进行测试
在刚刚新建的java项目下:
在 mm.test.webservices.axis2userguide 包下
新建 : SampleClient.java 内容如下:
package mm.test.webservices.axis2userguide; 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.addressing.EndpointReference; import org.apache.axis2.client.Options; import org.apache.axis2.Constants; import org.apache.axis2.client.ServiceClient; public class SampleClient { private static EndpointReference targetEPR = new EndpointReference( "http://localhost:8080/axis2/services/UserGuideSampleService"); public static OMElement greetUserPayload(String personToGreet) { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace( "http://example1.org/example1", "example1"); OMElement method = fac.createOMElement("sayHello", omNs); OMElement value = fac.createOMElement("personToGreet", omNs); value.addChild(fac.createOMText(value, personToGreet)); method.addChild(value); return method; } public static void main(String[] args) { try { OMElement payload = SampleClient.greetUserPayload("John"); Options options = new Options(); options.setTo(targetEPR); options.setTransportInProtocol(Constants.TRANSPORT_HTTP); ServiceClient sender = new ServiceClient(); sender.setOptions(options); OMElement result = sender.sendReceive(payload); String response = result.getFirstElement().getText(); System.out.println(response); } catch (Exception e) { // (XMLStreamException e) { System.out.println(e.toString()); } } }
右键运行下,如果发现控制台输出:
Hello, John
说明:调用服务成功。
发表评论
-
activiti注释Annotation生成图片后乱码问题解决
2016-04-18 18:49 1264activiti的版本:5.15.1 直接看图: ... -
EasyUI-combobox-监听onblur事件
2014-04-17 17:41 3992$("#id").combobox(). ... -
EasyUI-datagrid-自动合并单元格
2014-03-28 09:43 127861.目标 1.1表格初始化完成后,已经自动合并好需要 ... -
FATAL ERROR in native method: JDWP No transports initialized
2012-12-07 14:27 14203今天在启动MyEclipse里面配置的Tomcat的时候(DE ... -
operamasks-ui之omGrid简单使用
2012-06-19 22:40 189991.背景 1)本文只是简单记录下怎么使用operamasks ... -
使用SpringMVC(spring3.0)自带的json
2012-03-13 17:22 79921.下载spring相关jar 去哪里下载就不说了 要想支 ... -
使用XBlink操作XML
2012-01-14 12:49 29271.为什么使用XBlink? 两个项目进行交互, ... -
使用Nutz的文件池和上传功能实现上传图片
2011-05-03 13:27 4062【阅读本文前提】 您了解Nutz框架(刚刚接触N ... -
使用Nutz的json视图实现前台密码验证
2011-04-20 12:32 1531使用Nutz的json视图实现前台密码验证 【阅 ... -
能说明你的Javascript技术很烂的五个原因(转)
2011-04-13 12:40 1175Javascript在互联网上名声很臭,但你又很难再找到一个像 ... -
如何在android模拟器中安装和卸载APK包
2011-03-14 16:27 2375【安装APK】 安装前最好先把模拟器打开。下面举例说明 ... -
Android学习笔记
2011-03-02 21:38 1417Android学习笔记 1.改变AVD地址 ... -
oracle-学习笔记-5
2010-12-17 10:43 1822接 oracle-学习笔记-4 --- ... -
oracle-学习笔记-4
2010-12-17 10:42 1813接 oracle-学习笔记-3 ------------- ... -
oracle-学习笔记-3
2010-12-17 10:40 1254接 oracle-学习笔记-2 -------------- ... -
oracle-学习笔记-2
2010-12-17 10:39 1180接 oracle-学习笔记-1 ------------- ... -
oracle-学习笔记-1
2010-12-17 10:37 1468本文如同题目,只是学习笔记 1.1查看控制文件 SQL> ... -
Weblogic8.1 SSL的配置
2010-07-08 14:53 1337Weblogic SSL的配置 1) 先进入域所在的地 ... -
机试笔试面试题
2009-12-12 11:35 2411机试笔试面试题(主要是Java,其次是ASP.net,C#,O ... -
ExtJs资料
2009-11-27 18:04 2294从网上找了一些和ExtJs有关的资料,有需要的就下载吧! ...
相关推荐
axis2入门及简单例子
Axis的简单准备 Axis的入门实例 Axis复杂对象类型的WebService Axis的辅助工具发布、调用WebService Axis WebService会话Session的管理 Axis用控制台Dos命令发布WebService Axis跨多个WebService管理Session Axis用...
Axis 的简单准备 Axis 的入门实例 Axis 复杂对象类型的WebService Axis 的辅助工具发布、调用WebService Axis WebService 会话Session 的管理 Axis 用控制台Dos 命令发布WebService Axis 跨多个WebService 管理...
Axis的简单准备 Axis的入门实例 Axis复杂对象类型的WebService Axis的辅助工具发布、调用WebService Axis WebService会话Session的管理 Axis用控制台Dos命令发布WebService Axis跨多个WebService管理Session ...
axis使得webservice相当简单,半天就可以精通
Axis的简单准备 Axis的入门实例 Axis复杂对象类型的WebService Axis的辅助工具发布、调用WebService AxisWebService会话Session的管理 Axis用控制台Dos命令发布WebService Axis跨多个WebService管理Session Axis用...
Axis的简单入门实例 Axis的jws发布WebService Axis的wsdd模式发布WebService Axis中传递复杂对象和内部类 Axis中的handler、chain的特性 Axis中处理异常信息 Axis中传递文件信息 Axis常用命令介绍 Axis 提供的工具和...
axis2入门学习资料,通过10个步骤详细例子(测试都能运行),简单阐述了ajax通过tomcat发布方法,session管理,异步调用和同步调用,spring整合等功能,说明,配置比较详细
NULL 博文链接:https://qiangjiyi.iteye.com/blog/2223655
学习webservice必不可少的资料,入门简单
3.1. Axis2的简单WebService示例 10 3.1.1. 0配置POJO的Webservice 10 3.1.2. 用axis2的辅助工具发布、调用WebService 12 3.1.3. WebService会话Session的管理 24 3.1.4. 用Spring创建的JavaBean发布成WebService 29...
axis入门,简单实用 包括三个人的博客文章
自己写的一个简单的axis的java webservice,希望入门的学习者有用。
一个简单的Axis例子. eclipse工程代码,服务器端代码和客户端代码都有.能直接运行,对入门级的朋友来说不错.
java webservice AXIS,XFire , CXF介绍,包含简单的CFX例子,对于初步接触、入门有帮助。
如何在 System Manager 中独立硬件的 Axis 配置和调试界面;TwinCAT PLC Control 中独立于硬件的单轴及多轴运动控制程序的编写;完整的 AX5000 和电机参数的设置;以及电子凸轮表、飞锯、TwinCAT NC FIFO 等功能。
最简单的webservice的例子,包括服务端与客户端,有axis、xfire的两种方式的实现
Eclipse开发WEBSERVICE示例HELLWORD源码,最简单的入门示例,含client和Services端 1)导入ecplise中,eclipse需要先配置好tomcat+axis2环境; 2)用eclipse的 axis2插件菜单发布Hellword Service到tomcat中 3)...
5、简单功能分析——截屏功能和“关于”窗体分析、功能分析——Show Planet Axis、Show Position 、Show Cross Hairs功能插件加载过程全解析 6、渲染过程解析篇 7、LoadUnload Plugins——投石问路篇 8、LoadUnload ...