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下需要加入三個(gè)包 activation.jar、mail.jar、tools.jar,注意這三個(gè)包是必須的,盡管tools.jar很常見(jiàn),但這也是運(yùn)行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(
          "返回結(jié)果:" + ret);
              }
          }

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

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

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 云浮市| 利辛县| 长子县| 铜陵市| 靖江市| 罗甸县| 新竹县| 松江区| 泸州市| 湘阴县| 双柏县| 威远县| 梓潼县| 襄城县| 宣城市| 北川| 岫岩| 揭西县| 衡阳县| 云霄县| 闽侯县| 华池县| 云浮市| 原阳县| 沁水县| 呼玛县| 普格县| 辽宁省| 汝阳县| 台东市| 高碑店市| 中超| 朝阳市| 界首市| 龙川县| 老河口市| 区。| 德令哈市| 庄浪县| 玛沁县| 江永县|