网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Java
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.Eclips使用秘技(绝对经典).
.开发手机游戏的一点心得(一).
.安装Struts需要的软件.
.java设计模式之 Composite(组合).
.详细介绍声音处理.
.Java Socket编程(二).
.java设计模式之Composite(组合).
.Java技巧:在对标准流进行重定向.
.J2ME概述.
.插件Java Plugin Fram.
.Java中鲜为人知的缺点(下).
.Java中文档对象模型DOM经验小结.
.垃圾自动收集系统指导(2).
.Java EJB技术研究.
.JDBCTM 指南:入门7 - CallableS.
.XDE中模式驱动的设计与开发(三).
.测试要考虑成本、粒度和角度问题.
.JavaRMI入门实战.
.round 方法.
.JAVA数据结构示例---逆波兰式求值.

Web Service实现包--AXIS2学习笔记一

发表日期:2008-1-5



  我比较懒惰,不想把user guide全部翻译,就记录一些点吧。
  
  Axis2是全新设计的,在2004年的“Axis峰会”上,大家决定采用新的架构来让Axis更加的富有弹性,更有效率,并且更加的可配置。Axis2现在具有的一些feature:
  Speed
  Low memory foot print
  AXIOM - AXis Object Model
  Hot Deployment
  Asynchronous Web Services
  MEP Support - Message Exchange Patterns
  Flexibility
  Stability
  Component-oriented deployment
  Transport framework
  WSDL support
  
  有些feature现在看不懂,还是先动手做一下,感性熟悉一下吧
  
  第一步:下载AXIS2。http://ws.apache.org/axis2/download.cgi。很有趣,在apache的Web Service 的Project目录下面还看不到AXIS2。要下那个binary的版本,因为里面有例程。
  
  第二步:Copy axis2.war到$TOMCAT_HOME/webapps目录下面。Tomcat似乎只能用JDK1.4,我在JDK1.5 用不出来。
  
  第三步:打开 http://localhost:8080/axis2,就可以看到axis2的Welcome页面了。点一下Validate 和Services,看是不是都没有错误。都没有错误的话,就表示deploy成功了。那个adminstration页面可以通过上传文件来hot deploy Web service,可以用来remote deploy。
  
  第四步:研究例程。先从"samples/userguide/src"目录下的例程看起。看到写一个web service很简单嘛:
  
  public class MyService {
  public OMElement echo(OMElement element) throws XMLStreamException {
  //Praparing the OMElement so that it can be attached to another OM Tree.
  //First the OMElement should be completely build in case it is not fully built and still
  //some of the xml is in the stream.
  element.build();
  //Secondly the OMElement should be detached from the current OMTree so that it can be attached
  //some other OM Tree. Once detached the OmTree will remove its connections to this OMElement.
  element.detach();
  return element;
  }
  
  public void ping(OMElement element) throws XMLStreamException {
  //Do some processing
  }
  public void pingF(OMElement element) throws AxisFault{
  throw new AxisFault("Fault being thrown");
  }
  }
  
  看得出来,函数统一使用OMElement作为参数。在META-INF目录下面有个services.xml文件:
  <service name="MyService">
  <description>
  This is a sample Web Service with two operations,echo and ping.
  </description>
  <parameter name="ServiceClass" locked="false">userguide.example1.MyService</parameter>
  <operation name="echo">
  <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
  </operation>
  <operation name="ping">
  <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
  </operation>
  </service>
  呵呵,也很简单嘛。有返回值的就用RawXMLINOutMessageReceiver,没返回值的就用RawXMLINOnlyMessageReceiver。把它们编译(要把axis2的jar写到classpath里去)打包压到 MyService.aar,包里文件目录如下:
  ./\META-INF/services.xml
  ./userguide/example1/MyService.class
  把MyService.aar拷贝到$TOMCAT_HOME/webapps/axis2/WEB-INF/services,然后去点一下http://localhost:8080/axis2页面上的Services,也就是http://localhost:8080/axis2/listServices.jsp,就可以看到MyService已经被列出来了。
  
  关于调用web service的东西蛮多,下次写吧。
上一篇:技术分析:将Web站点转换为Web服务二(组图) 人气:603
下一篇:技术分析:将Web站点转换为Web服务一(组图) 人气:686
浏览全部Java的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐