建立https型的webServices

1.下載axis2 地址: http://archive.apache.org/dist/axis/axis2/java/core/1.5.4/axis2-1.5.4-bin.zip
2.建立Axis2Service2 web項目。並在src文件夾下建立 TestHelloWord.java 文件
   
package ws;

    /**
     * @author Loong (smm_h@163.com)
     * @date 2012-4-20 上午10:48:50
     *
     * @description
     *
     * @version
     */
    public class TestHelloWord {
       
        public String helloWord(String xmlString){
            return "<admin>Loong<admin/>" + xmlString ;
        }
    }
3.將axis2下的conf文件夾拷貝到項目WEB-INF下
4.將axis2下的lib包導入到項目中,再將repository目錄下的modules目錄拷貝放入WEB-INF文件夾下。
5.在項目WEB-INF下建立services
                                     └─AxisService
                                              └─META-INF  文件夾。 再建立services.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
    <serviceGroup>
        <service name="helloService0001">
            <description>helloWordService</description>
            <parameter name="ServiceClass">ws.TestHelloWord</parameter>
            <operation name="helloWord">
                <messageReceiver  class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
            </operation>
        </service>
    </serviceGroup>
6.在web.xml文件中配置axis的servlet
<servlet>
        <servlet-name>AxisServlet</servlet-name>
        <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>AxisServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
7.啓動tomcat服務器 , 在瀏覽器中輸入http://localhost:8443/Axis2Service2/services/helloService0001?wsdl 就能夠訪問了 8. 轉換爲https 只須要修改conf目錄下的axis2.xml文件 查找transportReceiver 將name="http" 改成 name="https"就好了     訪問路徑:https://localhost:8443/Axis2Service2/services/helloService0001?wsdl
相關文章
相關標籤/搜索