posts - 32,comments - 8,trackbacks - 0

          reference:

          http://www.cnblogs.com/cy163/archive/2008/11/28/1343516.html

          pre-condition:
          1.install eclipse
          2.install tomcat plugin

          process:
          1.download axis lib: http://ws.apache.org/axis

          2. set classpath:
          1.AXIS_HOME
          D:\Java\axis-1_4(這是我的Axis路徑)
          2.AXIS_LIB
          %AXIS_HOME%\lib
          3.AXIS_CLASSPATH
          %AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery-0.2.jar;%AXIS_LIB%\commons-logging-1.0.4.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;%AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\xml-apis.jar;%AXIS_LIB%\xercesImpl.jar;%AXIS_LIB%\wsdl4j-1.5.1.jar;%AXIS_LIB%\activation.jar;%AXIS_LIB%\xmlrpc-2.0.jar
          4.CLASSPATH
          .;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar; %AXIS_CLASSPATH%;
          5.在你的%TOMCAT_HOME%\common\lib下需要加入三個包 activation.jar、mail.jar、tools.jar,注意這三個包是必須的,盡管tools.jar很常見,但這也是運行Axis所必須的包。


          3.FIle - new - dynamic web project
          projectname: oopsaxis1
          target runtime: apache tomcat V5.5


          4. oopsaxis1/WebContent/WEB-INF/lib,add lib from %AXIS_HOME%\lib
          axis.jar/axis-ant.jar/commons-log.jar...

          5.oopsaxis1/WebContent/WEB-INF/web.xml,  replace by %AXIS_HOME%\webapps\axis\WEB-INF\web.xml

          6.oopsaxis1/src, add java file:
          public class myService
          {
              
          public String getusername(String name)
              {
                  
          return "Hello " + name + ",this is an Axis DII Web Service";
              }
          }


          7.copy myService to oopsaxis1/WebContent, and rename to myService.jws

          8. right click myService.jws, run as - run on server, you can see:
          http://localhost:8080/oopsaxis1/myService.jws
          There is a Web Service here
          Click to see the WSDL 
          click the link, you can see the wsdl


          9. in eclipse - package explorer - src, new class:
          package com.oopsaxis;

          import java.net.MalformedURLException;
          import java.rmi.RemoteException;

          import javax.xml.rpc.ParameterMode;
          import javax.xml.rpc.ServiceException;

          import org.apache.axis.client.Call;
          import org.apache.axis.client.Service;
          import org.apache.axis.encoding.XMLType;

          public class myServiceTestorByjws
          {
              
          public static void main(String[] args) throws ServiceException,
                      MalformedURLException, RemoteException
              {
                  String endpoint 
          = http://localhost:8080/oopsaxis1/myService.jws;
                  String name 
          = " pixysoft";
                  Service service 
          = new Service();
                  Call call 
          = (Call) service.createCall();

                  call.setTargetEndpointAddress(
          new java.net.URL(endpoint));
                  call.addParameter(
          "param1", XMLType.XSD_STRING, ParameterMode.IN);
                  call.setOperationName(
          "getusername");
                  call.setReturnType(XMLType.XSD_STRING);
                  String ret 
          = (String) call.invoke(new Object[] { name });
                  System.out.println(
          "返回結果:" + ret);
              }
          }

          10. right click myServiceTestorByjws, run as java application,you get:
          返回結果:Hello pixysoft,this is an Axis DII Web Service

          done!
          posted on 2008-12-17 13:40 張辰 閱讀(269) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 湛江市| 珠海市| 竹溪县| 三穗县| 淮安市| 上饶县| 江口县| 泸州市| 都兰县| 剑阁县| 崇左市| 武宣县| 沂水县| 新乡市| 长岭县| 天气| 盐源县| 象州县| 阿勒泰市| 赤峰市| 宝鸡市| 安国市| 都昌县| 泾源县| 宣恩县| 马边| 桂平市| 汉阴县| 寻甸| 灵丘县| 磴口县| 正镶白旗| 芜湖市| 凤阳县| 咸阳市| 醴陵市| 林西县| 南充市| 濉溪县| 开阳县| 杭锦后旗|