首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Tomcat+Axis2 SSL兑现

2012-10-08 
Tomcat+Axis2 SSL实现给WebService 添加SSL支持 ?1.Environment ? Eclipse 3.7 ? Tomcat 6.0 ? Axis2 war(

Tomcat+Axis2 SSL实现

给WebService 添加SSL支持


?

1.Environment

? Eclipse 3.7

? Tomcat 6.0

? Axis2 war(1.5.×)


?

2.Tomcat 设置Axis2

http://chenhailong.iteye.com/admin/blogs/905865


?

3.tomcat设置SSL

?在tomcat目录找到conf目录下service.xml

添加下面:

   <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"               maxThreads="150" scheme="https" secure="true"               clientAuth="false" sslProtocol="TLS" />


?

4.在axis2 目录下找到web.xml

添加下面:

    <servlet>        <servlet-name>AxisServlet</servlet-name>        <display-name>Apache-Axis Servlet</display-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>


?

5.在axis2目录下conf目录找到axis2.xml

添加下面:

<transportReceiver name="http" name="code">import org.apache.axis.client.Call;import org.apache.axis.client.Service;import javax.xml.namespace.QName;  public class TestClient { public static void main(String [] args) {  try {    String endpoint = "https://localhost:8443/axis/services/××××?wsdl";    System.setProperty("javax.net.ssl.trustStore",     "store目录");    Service service = new Service();    Call    call    = (Call) service.createCall();    call.setTargetEndpointAddress( new java.net.URL(endpoint) );    call.setOperationName(new QName("echoString"));    String ret = (String) call.invoke( new Object[] { "Hello!" } );    System.out.println("Sent 'Hello!', got '" + ret + "'");  } catch (Exception e) {    System.err.println(e.toString());  } }}

热点排行