国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

Web Service實(shí)現(xiàn)包--AXIS2學(xué)習(xí)筆記一

2019-11-18 12:51:09
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

  我比較懶惰,不想把user guide全部翻譯,就記錄一些點(diǎn)吧。
  
  Axis2是全新設(shè)計(jì)的,在2004年的“Axis峰會(huì)”上,大家決定采用新的架構(gòu)來(lái)讓Axis更加的富有彈性,更有效率,并且更加的可配置。Axis2現(xiàn)在具有的一些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現(xiàn)在看不懂,還是先動(dòng)手做一下,感性熟悉一下吧
  
  第一步:下載AXIS2。http://ws.apache.org/axis2/download.cgi。很有趣,在apache的Web Service 的Project目錄下面還看不到AXIS2。要下那個(gè)binary的版本,因?yàn)槔锩嬗欣獭?br />  
  第二步:Copy axis2.war到$TOMCAT_HOME/webapps目錄下面。Tomcat似乎只能用JDK1.4,我在JDK1.5 用不出來(lái)。
  
  第三步:打開(kāi) http://localhost:8080/axis2,就可以看到axis2的Welcome頁(yè)面了。點(diǎn)一下Validate 和Services,看是不是都沒(méi)有錯(cuò)誤。都沒(méi)有錯(cuò)誤的話,就表示deploy成功了。那個(gè)adminstration頁(yè)面可以通過(guò)上傳文件來(lái)hot deploy Web service,可以用來(lái)remote deploy。
  
  第四步:研究例程。先從"samples/userguide/src"目錄下的例程看起。看到寫(xiě)一個(gè)web service很簡(jiǎn)單嘛:
  
  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");
  }
  }
  
  看得出來(lái),函數(shù)統(tǒng)一使用OMElement作為參數(shù)。在META-INF目錄下面有個(gè)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>
  呵呵,也很簡(jiǎn)單嘛。有返回值的就用RawXMLINOutMessageReceiver,沒(méi)返回值的就用RawXMLINOnlyMessageReceiver。把它們編譯(要把a(bǔ)xis2的jar寫(xiě)到classpath里去)打包壓到 MyService.aar,包里文件目錄如下:
  .//META-INF/services.xml
  ./userguide/example1/MyService.class
  把MyService.aar拷貝到$TOMCAT_HOME/webapps/axis2/WEB-INF/services,然后去點(diǎn)一下http://localhost:8080/axis2頁(yè)面上的Services,也就是http://localhost:8080/axis2/listServices.jsp,就可以看到MyService已經(jīng)被列出來(lái)了。
  
  關(guān)于調(diào)用web service的東西蠻多,下次寫(xiě)吧。

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 神木县| 墨江| 曲靖市| 小金县| 浪卡子县| 清涧县| 海淀区| 萨迦县| 石首市| 宁河县| 汶川县| 蕉岭县| 沙坪坝区| 若尔盖县| 陆河县| 奉贤区| 三原县| 衡山县| 洪泽县| 台中市| 钟祥市| 景宁| 梅河口市| 龙州县| 阿合奇县| 普安县| 松溪县| 鹤山市| 靖西县| 湟中县| 元朗区| 西平县| 慈利县| 环江| 闽清县| 南澳县| 洛南县| 三原县| 达尔| 平谷区| 曲松县|