posts - 32, comments - 153, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          Web Service學習日記-11月28日-Web Service部署

          Posted on 2006-11-28 21:00 Zou Ang 閱讀(757) 評論(1)  編輯  收藏 所屬分類:
          今天在宿舍,用Axis來弄了個最簡單的Web Service.先來講下怎么安裝和部署.
          首先,去Apache的網站下載Axis,我沒有下載Axis2,因為據說Axis2和Axis有比較多的不同,所以還是覺得先用以前的吧.
          下載好了以后,把axis下的webapp文件夾中的axis放到tomcat的webapp目錄下,然后啟動tomcat,輸入:http://localhost:8080/axis/,如果成功會看到歡迎頁面.
          然后寫一個Java類:
          import?java.util.HashMap;
          import?java.util.Map;

          /**
          ?*?2006-11-28
          ?*?
          @author?Zou?Ang
          ?*?Contact?<a?href?="mailto:richardeee@gmail.com">Zou?Ang</a>
          ?
          */

          public?class?BookTitleService?{

          ????Map
          <String,String>?books;
          ????
          public?BookTitleService(){
          ????????books?
          =?new?HashMap<String,String>();
          ????????
          ????????books.put(
          "0130895601","Advanced?Java?2?Platform?How?to?Program");
          ????????books.put(
          "0430895717","C++?How?to?Program,Third?edition");
          ????????books.put(
          "0430293636","Visual?Basic.?NET?How?to?Program");
          ????????books.put(
          "0130923613","Python?How?to?Program");
          ????}

          ????
          ????
          public?String?getBookTitle(String?ISBN){
          ????????
          return?books.get(ISBN);
          ????}

          }
          然后把BookTitleService.java更名為BookTitleService.jws,把更改后的文件放到%CATALINA_HOME%/webapps/axis/%包結構(比如org/apache/..)/目錄下
          ,我的是D:\apache-tomcat-5.5.17\apache-tomcat-5.5.17\webapps\axis\org\zsu\zouang\BookTitleService.jws,注意,這樣放好了jws文件后,把java類中的包名要刪除,做完了以后重新啟動tomcat,在地址欄輸入http://localhost:8080/axis/org/zsu/zouang/BookTitleService.jws,如果Web服務部署成功就會有頁面顯示的了,點Click to See WSDL后,可以看到:
          ?<?xml?version="1.0"?encoding="UTF-8"??>?
          -?
          <wsdl:definitions?targetNamespace="http://localhost:8080/axis/org/zsu/zouang/BookTitleService.jws"?xmlns:apachesoap="http://xml.apache.org/xml-soap"?xmlns:impl="http://localhost:8080/axis/org/zsu/zouang/BookTitleService.jws"?xmlns:intf="http://localhost:8080/axis/org/zsu/zouang/BookTitleService.jws"?xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"?xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"?xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"?xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          -?
          <!--?
          WSDL?created?by?Apache?Axis?version:?1.4
          Built?on?Apr?22,?2006?(06:55:48?PDT)

          ??
          -->?
          -?
          <wsdl:message?name="getBookTitleRequest">
          ??
          <wsdl:part?name="ISBN"?type="xsd:string"?/>?
          ??
          </wsdl:message>
          -?
          <wsdl:message?name="getBookTitleResponse">
          ??
          <wsdl:part?name="getBookTitleReturn"?type="xsd:string"?/>?
          ??
          </wsdl:message>
          -?
          <wsdl:portType?name="BookTitleService">
          -?
          <wsdl:operation?name="getBookTitle"?parameterOrder="ISBN">
          ??
          <wsdl:input?message="impl:getBookTitleRequest"?name="getBookTitleRequest"?/>?
          ??
          <wsdl:output?message="impl:getBookTitleResponse"?name="getBookTitleResponse"?/>?
          ??
          </wsdl:operation>
          ??
          </wsdl:portType>
          -?
          <wsdl:binding?name="BookTitleServiceSoapBinding"?type="impl:BookTitleService">
          ??
          <wsdlsoap:binding?style="rpc"?transport="http://schemas.xmlsoap.org/soap/http"?/>?
          -?
          <wsdl:operation?name="getBookTitle">
          ??
          <wsdlsoap:operation?soapAction=""?/>?
          -?
          <wsdl:input?name="getBookTitleRequest">
          ??
          <wsdlsoap:body?encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"?namespace="http://DefaultNamespace"?use="encoded"?/>?
          ??
          </wsdl:input>
          -?
          <wsdl:output?name="getBookTitleResponse">
          ??
          <wsdlsoap:body?encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"?namespace="http://localhost:8080/axis/org/zsu/zouang/BookTitleService.jws"?use="encoded"?/>?
          ??
          </wsdl:output>
          ??
          </wsdl:operation>
          ??
          </wsdl:binding>
          -?
          <wsdl:service?name="BookTitleServiceService">
          -?
          <wsdl:port?binding="impl:BookTitleServiceSoapBinding"?name="BookTitleService">
          ??
          <wsdlsoap:address?location="http://localhost:8080/axis/org/zsu/zouang/BookTitleService.jws"?/>?
          ??
          </wsdl:port>
          ??
          </wsdl:service>
          ??
          </wsdl:definitions>
          這樣,一個最最簡單的Web Service就部署成功了.

          評論

          # re: Web Service學習日記-11月28日-Web Service部署  回復  更多評論   

          2006-11-28 22:47 by Tauruser
          最最最簡單??!
          加油。
          排版好寬-_-
          主站蜘蛛池模板: 成武县| 桂平市| 武定县| 文登市| 永年县| 汪清县| 宜阳县| 四会市| 开江县| 枣阳市| 如东县| 弋阳县| 禹州市| 肥东县| 延川县| 民县| 托克托县| 郸城县| 手游| 四会市| 阿克苏市| 枣阳市| 玉门市| 溧水县| 荆门市| 凤冈县| 饶阳县| 安达市| 宜宾市| 纳雍县| 尼勒克县| 宣武区| 肃南| 襄垣县| 罗城| 本溪| 九寨沟县| 利川市| 聊城市| 鄂尔多斯市| 东平县|