免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

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

開發(fā)中遇到兩個難點:

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

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

 

下面分別談這兩個問題.

 

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

1.1   DEMO文件樣例

1.1.1          項目結構圖:

 

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

1.1.2          項目代碼介紹

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中需要注入的字符串

    /**

     * 實現(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的實例

       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.springframework.org/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>

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

1.1.4          配置web.xml 文件如下:

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

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

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

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

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

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

 

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

    <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>

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

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

    <listener>

        <listener-class>

            org.springframework.web.context.ContextLoaderListener

        </listener-class>

    </listener>

 

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

 你的項目文檔中將會產(chǎn)生以下幾個文件夾或文件:

       JaxRpcHelloWorldService

       server-config.wsdd

       wsdl

              axRpcHelloWorld.wsdl

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

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

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

1.1.7          編寫測試類

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)建調用對象

       Service service = new Service(); 

       Call call = null; 

       call = (Call) service.createCall(); 

       // 調用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 可能和你的不一樣,請注意修改

1.1.8          運行測試類,結果如下:

1.1.9           

 

 

 

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


本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
web service開發(fā)的完整示例
Java WebService入門實例
CXF方式發(fā)布WebService全步驟
CXF MyEclipse 開發(fā)webservice入門實例之HelloWorld
開發(fā)webservice應用程序 [Java]
轉:用Java調用WebService接口 - jinesin隨筆 - jinesin - 和訊博客
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服