乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      在集成Spring Axis 的環(huán)境下webservice的發(fā)布和部署 - Aflye...

       不會(huì)游泳的魚 2007-06-15

      開發(fā)中遇到兩個(gè)難點(diǎn):

      1. 在集成Spring + Axis 的環(huán)境下webservice的發(fā)布和部署;

      2. 文件上傳和下載的commons-fileupload-1.2的使用。

       

      下面分別談這兩個(gè)問題.

       

      . 在集成Spring + Axis 的環(huán)境下webservice的發(fā)布和部署

      1.1   DEMO文件樣例

      1.1.1          項(xiàng)目結(jié)構(gòu)圖:

       

      (為了尊重原作者,我沒有替換包名)

      1.1.2          項(xiàng)目代碼介紹

      1.1.2.1 依次建立一下代碼文件

      ------------------------------------------------------------------------------------

      package com.test.www;

      import java.rmi.RemoteException;

      /**

       * @author fhway

       *

       */

      public interface IHelloWorld {

          public String getMessage(String name) throws RemoteException;

      }

      package com.test.www.impl;

      import com.test.www.IHelloWorld;

      /**

       * @author fhway

      */

      public class HelloWorldImpl implements IHelloWorld {

          private String helloStr; // Spring中需要注入的字符串

          /**

           * 實(shí)現(xiàn)接口中的方法,得到Say Hello to <somebody>的字符串

           */

          public String getMessage(String name) {

             return helloStr + ":" + name;

          }

          public String getHelloStr() {

             return helloStr;

          }

          public void setHelloStr(String helloStr) {

             this.helloStr = helloStr;

          }

          /**

           * @param args

           */

          public static void main(String[] args) {

             // TODO Auto-generated method stub

          }

      }

      package com.test.www.webservice;

      /**

       * @author fhway

      */

      import java.rmi.RemoteException;

      import javax.xml.rpc.ServiceException;

      import org.springframework.remoting.jaxrpc.ServletEndpointSupport;

      import com.test.www.IHelloWorld;

      public class JaxRpcHelloWorld extends ServletEndpointSupport implements

             IHelloWorld {

          private IHelloWorld helloWorld;

          protected void onInit() throws ServiceException {

             // Spring容器中獲取Bean的實(shí)例

             helloWorld = (IHelloWorld) getApplicationContext()

                    .getBean("helloWorld");

          }

          public String getMessage(String name) throws RemoteException {

             // 執(zhí)行Bean中的相同的方法

             return helloWorld.getMessage(name);

          }

      }

      基于以上文件,不用多做解釋

       

      1.1.3          Myeclipse加入【Add Spring Capabilities……

      得到文件applicationContext.xml 并放在WEB-INF 下面。內(nèi)容如下:

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www./dtd/spring-beans.dtd">

      <beans>

          <bean id="helloWorld" class="com.test.www.impl.HelloWorldImpl">

             <property name="helloStr">

                 <value>Say Hello to :</value>

             </property>

          </bean>

       

      </beans>

      這點(diǎn)和原文的照本宣課可能不一樣。我沒有配置XXXX.service.xml文件 在該文件中注入一個(gè)bean的參數(shù):【Say Hello to : 用于輸出的時(shí)候使用。

      1.1.4          配置web.xml 文件如下:

      <?xml version="1.0" encoding="UTF-8"?>

      <web-app id="WebApp_ID" version="2.4"

          xmlns="http://java./xml/ns/j2ee"

          xmlns:xsi="http://www./2001/XMLSchema-instance"

          xsi:schemaLocation="http://java./xml/ns/j2ee http://java./xml/ns/j2ee/web-app_2_4.xsd">

          <display-name>HelloWorld_SpringAxisSample</display-name>

       

          <!-- Spring框架需要引入的配置文件及相關(guān)類 -->

          <context-param>

             <param-name>contextConfigLocation</param-name>

             <param-value>/WEB-INF/applicationContext.xml</param-value>

          </context-param>

          <servlet>

             <servlet-name>context</servlet-name>

             <servlet-class>

                 org.springframework.web.context.ContextLoaderServlet

             </servlet-class>

             <load-on-startup>1</load-on-startup>

          </servlet>

          <servlet>

             <display-name>Apache-Axis Servlet</display-name>

             <servlet-name>AxisServlet</servlet-name>

             <servlet-class>

                 org.apache.axis.transport.http.AxisServlet

             </servlet-class>

          </servlet>

          <servlet>

             <display-name>Axis Admin Servlet</display-name>

             <servlet-name>AdminServlet</servlet-name>

             <servlet-class>

                 org.apache.axis.transport.http.AdminServlet

             </servlet-class>

             <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>AdminServlet</servlet-name>

             <url-pattern>/servlet/AdminServlet</url-pattern>

          </servlet-mapping>

          <welcome-file-list>

             <welcome-file>index.html</welcome-file>

             <welcome-file>index.htm</welcome-file>

             <welcome-file>index.jsp</welcome-file>

             <welcome-file>default.html</welcome-file>

             <welcome-file>default.htm</welcome-file>

             <welcome-file>default.jsp</welcome-file>

          </welcome-file-list>

      </web-app>

      后段關(guān)于axis的部分在你發(fā)布wsdl的時(shí)候也會(huì)自動(dòng)生成的,所以現(xiàn)帖出來;

      在配置【org.springframework.web.context.ContextLoaderServlet】的上下文時(shí),我們可以配置一個(gè)Servlet; 也可以做一個(gè)【listener

          <listener>

              <listener-class>

                  org.springframework.web.context.ContextLoaderListener

              </listener-class>

          </listener>

       

      1.1.5          利用wtp平臺(tái)提供的自動(dòng)話生成工具發(fā)布你的WebService

       你的項(xiàng)目文檔中將會(huì)產(chǎn)生以下幾個(gè)文件夾或文件:

             JaxRpcHelloWorldService

             server-config.wsdd

             wsdl

                    axRpcHelloWorld.wsdl

      1.1.6          如果你在發(fā)布的時(shí)候啟動(dòng)了你的Tomcat WebLogic 那么你就會(huì)看見以下的畫面

      IE:    =    http://localhost:8088/HelloWorld_SpringAxisSample/services/JaxRpcHelloWorld

      IE: = http://localhost:8088/HelloWorld_SpringAxisSample/services/JaxRpcHelloWorld?wsdl

      1.1.7          編寫測(cè)試類

      package com.test.www.webservice;

      import javax.xml.namespace.QName;

      import org.apache.axis.client.Call;

      import org.apache.axis.client.Service;

      public class TestWebServiceClient {

          /**

           * @param args

           */

          public static void main(String[] args) { 

             // TODO Auto-generated method stub

             try { 

             String wsdlUrl = "http://localhost:8088/HelloWorld_SpringAxisSample/services/JaxRpcHelloWorld?wsdl"; 

             String nameSpaceUri = "http://localhost:8088/HelloWorld_SpringAxisSample/services/JaxRpcHelloWorld"; 

              // 創(chuàng)建調(diào)用對(duì)象

             Service service = new Service(); 

             Call call = null; 

             call = (Call) service.createCall(); 

             // 調(diào)用sayHello

             System.out.println(">>>getMessage");

             /* Webservice name; methd name */

             call.setOperationName(new QName(nameSpaceUri, "getMessage")); 

             call.setTargetEndpointAddress(new String(wsdlUrl));

             String ret = (String) call.invoke(new Object[] { "ABC" }); 

             System.out.println("return value is " + ret); 

             } catch (Exception e) { 

             e.printStackTrace(); 

             } 

          }

      }

      我的tomcat8088 可能和你的不一樣,請(qǐng)注意修改

      1.1.8          運(yùn)行測(cè)試類,結(jié)果如下:

      1.1.9           

       

       

       

      Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1593309


        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多