Terry.Li-彬

          虛其心,可解天下之問;專其心,可治天下之學(xué);靜其心,可悟天下之理;恒其心,可成天下之業(yè)。

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            143 隨筆 :: 344 文章 :: 130 評論 :: 0 Trackbacks
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(19)

          隨筆分類(107)

          隨筆檔案(141)

          文章分類(284)

          文章檔案(342)

          相冊

          收藏夾(58)

          家裝

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          我比較懶惰,不想把user guide全部翻譯,就記錄一些點(diǎn)吧。

            Axis2是全新設(shè)計(jì)的,在2004年的“Axis峰會(huì)”上,大家決定采用新的架構(gòu)來讓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)手做一下,感性認(rèn)識(shí)一下吧

            第一步:下載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 用不出來。

            第三步:打開 http://localhost:8080/axis2,就可以看到axis2的Welcome頁面了。點(diǎn)一下Validate 和Services,看是不是都沒有錯(cuò)誤。都沒有錯(cuò)誤的話,就表示deploy成功了。那個(gè)adminstration頁面可以通過上傳文件來hot deploy Web service,可以用來remote deploy。

            第四步:研究例程。先從"samples/userguide/src"目錄下的例程看起。看到寫一個(gè)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");

            }

            }

            看得出來,函數(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>

            呵呵,也很簡單嘛。有返回值的就用RawXMLINOutMessageReceiver,沒返回值的就用RawXMLINOnlyMessageReceiver。把它們編譯(要把a(bǔ)xis2的jar寫到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頁面上的Services,也就是http://localhost:8080/axis2/listServices.jsp,就可以看到MyService已經(jīng)被列出來了。

            關(guān)于調(diào)用web service的東西蠻多,下次寫吧。
          posted on 2007-11-21 18:09 禮物 閱讀(454) 評論(0)  編輯  收藏 所屬分類: web service
          主站蜘蛛池模板: 武鸣县| 珲春市| 芦溪县| 府谷县| 九龙县| 德保县| 大石桥市| 抚松县| 迁西县| 衡阳市| 进贤县| 乐都县| 平舆县| 游戏| 彰化县| 定陶县| 永寿县| 怀安县| 安陆市| 台山市| 射洪县| 台南县| 米脂县| 江津市| 乌苏市| 栾川县| 濉溪县| 瑞昌市| 南川市| 明光市| 永吉县| 宁夏| 富阳市| 花莲市| 花垣县| 太谷县| 确山县| 旬邑县| 台安县| 兴宁市| 万山特区|