• axis1.4 集成web应用


    1、Installation Instructions  安装指导 (不常用)
     a) Step 1: Preparing the webapp
      Here we assume that you have a web server up and running on the localhost at port 8080.
      If your server is on a different port, replace references to 8080 to your own port number
      In your Application Server installation, you should find a directory into which web applications ("webapps") are to be placed.
      Into this directory copy the webapps/axis directory from the xml-axis distribution.
      实战:
      将下载好的axis 开发包解压到:C:\axis-1_4,并将C:\axis-1_4\webapps\下的axis 目录copy 到 tomcat web server下的webapps下。
      注意该拷贝的文件夹可以任意命名。
     b) Step 2: Setting up the libraries
      ①Axis needs to be able to find an XML parser,We recommend Xerces jars from the xml-xerces distribution.
      实战: 将xercesImpl.jar,xml-apis.jar 拷贝到axis\WEB-INF\lib下。
     c) Step 3: starting the web server
      实战:启动tomcat

     d) Step 4: Validate the Installation
      ①、Look for the start page
       在浏览器中输入: http://127.0.0.1:8080/axis/,You should now see an Apache-Axis start page.
       If you do not, then the webapp is not actually installed, or the appserver is not running
      ②、Validate Axis with happyaxis
       Follow the link Validate the local installation's configuration
       This will bring you to happyaxis.jsp a test page that verifies that needed and optional libraries are present.
       The URL for this will be something like http://localhost:8080/axis/happyaxis.jsp
       If any of the needed libraries are missing, Axis will not work.
       You must not proceed until all needed libraries can be found, and this validation page is happy.
       注意: 如果有相关的提示说该jar包在一个未知的位置(unkown location),这种情况视为jar包已经找到,不同于未找到的情况。
      ③、Look for some services
       From the start page, select View the list of deployed Web services.On this page,
       You should be able to click on (wsdl) for each deployed Web service to make sure that your web service is up and running

     e) Step 5: Installing new Web Services
      ①、The first step is to add your code to the server
       【1】In the WEB-INF directory, look for (or create) a "classes" directory (i.e. axis/WEB-INF/classes ). In this directory,
        copy the compiled Java classes you wish to install, being careful to preserve the directory structure of the Java packages
       【2】If your classes services are already packaged into JAR files, feel free to drop them into the WEB-INF/lib directory
        instead. Also add any third party libraries you depend on into the same directory.
      
      ②、After adding new classes or libraries to the Axis webapp, you must restart the webapp. This can be done by restarting your application server.
     f) Step 6: Deploying your Web Service
       Axis takes a Web Service Deployment Descriptor (WSDD) file that describes in XML what the service is, what methods it exports and other aspects of the SOAP endpoint.
      
      ①、Classpath setup
       windows :
          set JAVA_HOME=d:\jdk1.6
          set PATH = %JAVA_HOME%\bin
          set AXIS_HOME=c:\axis  
          set AXIS_LIB=%AXIS_HOME%\lib   
          set AXISCLASSPATH=%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery-0.2.jar.jar;%AXIS_LIB%\commons-logging.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
          set CLASSPATH=%JAVA_HOME%\lib;%AXISCLASSPATH%
       设置系统环境变量.

      ②、Find the deployment descriptor
        Deployment descriptors are an Axis-specific XML file that tells Axis how to deploy (or undeploy) a Web Service, and how to configure Axis itself
        The Axis 'engine' will update its configuration, then save its state.
        By default Axis saves it state into the global configuration file axis/WEB-INF/server-config.wsdd. Sometimes you see a warning message about
        such a file not being found--don't worry about this, because Axis auto-creates the file after you deploy something to it
      ③、Run the admin client
       java org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService deploy.wsdd

    2.高级安装(实战) Advanced Installation: adding Axis to your own Webapp
     a) Add axis.jar, wsdl.jar, saaj.jar, jaxrpc.jar and the other dependent libraries to your WAR file.
     b) Copy all the Axis Servlet declarations and mappings from axis/WEB-INF/web.xml and add them to your own web.xml
     c) Build and deploy your webapp.
     d) Run the Axis AdminClient against your own webapp, instead of Axis, by changing the URL you invoke it with.
    3.开发背景.有这样一个需求,第三方sp 要接入新疆vac系统,从而实现双方之间的交互。vac 事先定义了一个wsdl文件,双方基于该wsdl规范来开发对应的客户端,服务端功能。
     vac 作为客户端程序,sp 作为服务端,vac 调用sp 的webservice 接口,从而完成业务功能。我们作为sp,即服务端需要做到以下几点:
     a) jar 包
      axis.jar
      commons-discovery-0.2.jar
      commons-logging-1.0.4.jar
      jaxrpc.jar 
      log4j-1.2.8.jar
      saaj.jar
      wsdl4j-1.5.1.jar
      xerces.jar
      xml-apis.jar
     b) 修改web.xml
       <listener>
        <listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
       </listener>
        <!-- axis1.4 webservice集成 -->
         
        <servlet>
          <servlet-name>AxisServlet</servlet-name>
          <servlet-class>
       org.apache.axis.transport.http.AxisServlet
          </servlet-class>
        </servlet>

        <servlet>
          <servlet-name>AdminServlet</servlet-name>
          <servlet-class>
       org.apache.axis.transport.http.AdminServlet
          </servlet-class>
          <load-on-startup>100</load-on-startup>
        </servlet>

        <servlet>
          <servlet-name>SOAPMonitorService</servlet-name>
          <servlet-class>
       org.apache.axis.monitor.SOAPMonitorService
          </servlet-class>
          <init-param>
            <param-name>SOAPMonitorPort</param-name>
            <param-value>5001</param-value>
          </init-param>
          <load-on-startup>100</load-on-startup>
       </servlet>


       <servlet-mapping>
          <servlet-name>AxisServlet</servlet-name>
          <url-pattern>/servlet/AxisServlet</url-pattern>
      </servlet-mapping>

      <servlet-mapping>
          <servlet-name>AxisServlet</servlet-name>
          <url-pattern>*.jws</url-pattern>
      </servlet-mapping>

      <servlet-mapping>
          <servlet-name>AxisServlet</servlet-name>
          <url-pattern>/services/*</url-pattern>
      </servlet-mapping>

      <servlet-mapping>
          <servlet-name>SOAPMonitorService</servlet-name>
          <url-pattern>/SOAPMonitor</url-pattern>
             </servlet-mapping>

      <mime-mapping>
              <extension>wsdl</extension>
               <mime-type>text/xml</mime-type>
      </mime-mapping>
     

      <mime-mapping>
              <extension>xsd</extension>
              <mime-type>text/xml</mime-type>
      </mime-mapping>
     c) 首先根据wsdl生成服务端代码。
      windows :
       c:\>java org.apache.axis.wsdl.WSDL2Java -s xx.wsdl
      代码包图:
      ...
     d) 完成服务端代码
      将服务端代码写到*impl.java 文件中
      SyncNotifySPSoapBindingImpl.java

      注意: 在一个基于B/S 的web 应用当中,为了完成业务代码,很多时候都会用到服务层代码。
      也就是说我们写接口的时候很少会孤立的去写一个服务端程序,既然要用到服务层代码,那么
      我们的问题就是如何在web应用获取一个单例的service层对象。
      首先声明一下,本应用采用的是基于spring的业务层架构。所以问题转换为如何在一个普通的java类
      中获取单例的bean.所谓普通的java类指没有与任何的servlet api 相耦合,但是它的加载需要web容器
      的支持。
      有几种解决方法:
      ①实现接口ApplicationContextAware : 在spring初始化时,自动将application进行注入
       实现setApplicationContext(ApplicationContext applicationContext);
       例如:
       public class WebApplicationUtil implements ApplicationContextAware{
        private static ApplicationContext application;
        
        public void setApplicationContext(ApplicationContext applicationContext)
        throws BeansException {
         application = applicationContext;
        }

        public static Object getBean(String beanName){
         return application.getBean(beanName);
         
        }
       }

      ②继承自抽象类ApplicationObjectSupport
       不需要实现任何方法,直接通过getApplicationContext();即可获取
      ③继承自抽象类WebApplicationObjectSupport
       类似②

      

      注意:>该工具类需要在spring配置文件中进行配置.<bean id="WebApplicationUtil" class="com.xjgs.util.WebApplicationUtil"></bean>
            >上述工具类使用的场景是在一个web 应用中,由web容器支持的普通java类中.
             而且该类的加载器必须是org.apache.catalina.loader.WebappClassLoader.

     e) 修改deploy.wsdd 文件.
      在c)步骤中,生成服务端skeleton时,生了一个部署文件.但是需要修改几个地方.
      ①<parameter name="className" value="com.pk.vac.webservice.sync.SyncNotifySPSoapBindingImpl"/> 修改成本应用的实现类包括包名.类名最好不变.
      ②有时候会用到po类: 注意java类型
        <typeMapping
        xmlns:ns="http://rsp.sync.soap.bossagent.vac.unicom.com"
        qname="ns:OrderRelationUpdateNotifyResponse"
        type="java:com.pk.vac.webservice.sync.rsp.OrderRelationUpdateNotifyResponse" ----> 这一行需要更改为本应用的po全限定名
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
             />
        <typeMapping
        xmlns:ns="http://req.sync.soap.bossagent.vac.unicom.com"
        qname="ns:OrderRelationUpdateNotifyRequest"
        type="java:com.pk.vac.webservice.sync.req.OrderRelationUpdateNotifyRequest" ----> 这一行需要更改为本应用的po全限定名
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
             />
     f) 启动tomcat 服务器
     g) 使用AdminClient 发布服务.
      windows:
      F:\webservice>java -Djava.ext.dirs=D:\workspace\项目名\WebRoot\WEB-INF\lib\   org.apache.axis.client.AdminClient -lhttp://localhost:port/services/
      AdminService vac_deploy.wsdd

      linux:
      [tomcat@cmcc_host ~]$ java -Djava.ext.dirs=/home/tomcat/项目名/WEB-INF/lib org.apache.axis.client.AdminClient -lhttp://localhost:port/services/AdminService deploy_vac.wsdd

      注意: java.ext.dirs = {lib}
          An optional package is a group of packages housed in one or more JAR files that implement an API that extends the Java platform.
       Optional package classes extend the platform in the sense that the virtual machine can find and load them without their being on the class path
       , much as if they were classes in the platform's core API.

        Other locations for installed optional packages can be specified through the system property java.ext.dirs.
      This property specifies one or more directories to search for installed optional packages,
      each separated by File.pathSeparatorChar.
      The default setting for this property is the standard directory for installed optional packages indicated above.
      

     h) test

  • 相关阅读:
    Atitit 人员成本优化 实习生制度 attilax总结 1.1. 适合领域 于测试 与 轻度运维领域 轻度研发开发领域 1 1.2. 适合领域 行政领域 1 1.3. 要不要适当发放点生活补贴
    Atitit dataindex rootindex cyarindex diaryindex meatindex v8 s99 recently data up dir s
    Atitit 前端与ui开发的技术道术与艺术 attilax著 1. 概述 2 1.1. 适用领域: ui相关领域(包括h5 web ios android安卓 cs桌面程序 游戏程序 等
    Atitit nosql的概念与attilax的理解 目录 1. 常见的nosql 二、Redis,Memcache,MongoDb的特点 1 HBase 1 2. Nosql的核心nosql 1
    Atitit 艾提拉博士带来“深度?广度?高度 人员的职业发展之路 ”的主题分享。 目录 1.1. 技术团队气氛的区别 开发架构模式 2 1.2. 技术人员的职业发展有哪些路线? 3 1.3. 主
    Atitit js通讯技术 jsbridge ajax bomext Atitit jsbridge 与jsrpc 的联系与区别 JSBridge——Web与Native交互 侧重本
    Atitit 微服务的优点和拆分 目录 1. 微服务架构五大优势 崛起势头不可挡 4 1 1.1. 1、复杂度可控 6避免“盲人摸象” 7 2 1.2. 2、灵活可扩展 7 2 1.3. 3、独立部
    Atitit外包优缺点 提升开发效率 外包模式 1.一般来说外包优点 1.1.更加方便快捷 时间成本降低了 1.2.会导致 经济成本高,,时间成本降低了, 2.缺点 2.1.成本高 2.2.
    Atitit 演讲常用肢体语言与手势总结 目录 1. 原则 ,哑语一样,手势不只是补充。。。 1 2. 比拟实际物体与抽象物体 1 2.1. 三个实用的手势: 1 2.2. (五)、演讲中忌讳的动作
    Atitit 前端 dom 的艺术 attilax著 目录 1. 概念 1 2. 发展历程 1 2.1. 厂商各自为政 2 2.2. 1.4 制定标准 标准化 w3cdom 2 2.3. 1.4.
  • 原文地址:https://www.cnblogs.com/sunormoon/p/2410024.html
Copyright © 2020-2023  润新知