`
sillycat
  • 浏览: 2551941 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

SOAP AXIS2 with HTTPS

    博客分类:
  • SOA
 
阅读更多
SOAP AXIS2 with HTTPS

1. sample configuration on tomcat7.0
server.xml

    <Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               keystoreFile="d:\tool\apache-tomcat-7.0.16\tomcat.jks"
               keystorePass="xxxxxx"/>

2. configuration in axis2.xml
    <transportSender name="https"
                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
        <parameter name="PROTOCOL">HTTP/1.1</parameter>
        <parameter name="Transfer-Encoding">chunked</parameter>
        <parameter name="port">443</parameter>
    </transportSender>

That is all for the server side.

3. Client side
We can call the https SOAP server with our client like this:
@Test
public void weatherService()
{
RPCServiceClient serviceClient = null;
       try
        {
        //http://www.httpdebugger.com/download.html
        String HTTPS_URL = "https://server/easyaxis/services/WeatherService";
        String HTTP_URL = "http://server:8080/easyaxis/services/WeatherService";
       
            serviceClient = new RPCServiceClient();
            Options options = serviceClient.getOptions();
            EndpointReference targetEPR = new EndpointReference(HTTP_URL);
            options.setTimeOutInMilliSeconds(1800000); // 10000 seconds
            options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
            options.setProperty(HTTPConstants.SO_TIMEOUT, 1800000);
            options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, 1800000);
            options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
            // client.getOptions().setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION, Boolean.TRUE);
            options.setExceptionToBeThrownOnSOAPFault(true);
            options.setTo(targetEPR);
           
            //SSL
            System.setProperty("javax.net.ssl.trustStore","d:\\tool\\apache-tomcat-7.0.16\\tomcat.jks");
            System.setProperty("javax.net.ssl.trustStorePassword","D1gby!");
           
            // Setting the weather
            QName opSetWeather = new QName("http://services.weather.axis2.sillycat.com", "setWeather");
            Weather w = new Weather();
            w.setTemperature((float) 39.3);
            w.setForecast("Cloudy with showers");
            w.setRain(true);
            w.setHowMuchRain((float) 4.5);
            Object[] opSetWeatherArgs = new Object[] { w };

            serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);

            // Getting the weather
            QName opGetWeather = new QName("http://services.weather.axis2.sillycat.com", "getWeather");
            Object[] opGetWeatherArgs = new Object[] {};
            @SuppressWarnings("rawtypes")
Class[] returnTypes = new Class[] { Weather.class };
            Object[] response = serviceClient.invokeBlocking(opGetWeather, opGetWeatherArgs, returnTypes);

            Weather result = (Weather) response[0];

            if (result == null)
            {
                System.out.println("Weather didn't initialize!");
                return;
            }
            // Displaying the result
            System.out.println("Temperature               : " + result.getTemperature());
            System.out.println("Forecast                  : " + result.getForecast());
            System.out.println("Rain                      : " + result.isRain());
            System.out.println("How much rain (in inches) : " + result.getHowMuchRain());
        }
        catch (Exception e)
        {
            System.out.println("error:" + e);
        }
        finally
        {
            try
            {
                // clear up
                serviceClient.cleanupTransport();
            }
            catch (Exception e)
            {
                System.out.println("error:" + e);
            }
        }
    }

4. Moniters

First of all, we can use the HttpAnalyzer to watch the data, but it only work for the HTTP, not HTTPS.

Then I tried the SOAP monitor. That works.

references:
http://shivendra-tripathi.blogspot.com/2010/11/enabling-ssl-for-axis2-service-and.html
http://axis.apache.org/axis2/java/core/docs/http-transport.html#httpsupport
http://www.opensubscriber.com/message/axis-dev@ws.apache.org/8077606.html
http://techtidbitsbyshiv.blogspot.com/2010/11/axis2java-client-code-for-basic.html


分享到:
评论

相关推荐

    axis2-1.6.1

    - 多协议支持:除了基本的SOAP 1.1和1.2,Axis2还支持REST、MTOM(Message Transmission Optimization Mechanism)和SwA(Soap with Attachments)等传输方式。 - 高效的消息处理:使用了基于内存的数据结构,Axis2...

    axis 1.x与axis2.x开发

    它还支持MTOM(Message Transmission Optimization Mechanism)和SwA(Soap with Attachments),有效优化了带有二进制数据的Web服务传输。 在开发过程中, Axis1.x和Axis2.x的使用方式也有所不同。Axis1.x通常通过...

    Developing webService with axis2

    ### 使用Apache Axis2开发Web服务的关键知识点 #### 一、Apache Axis2简介 Apache Axis2是用于构建和服务Web服务的强大框架。它支持多种标准,包括SOAP、WSDL、MTOM等,并提供了丰富的功能来实现安全性和高效的...

    eclipse java axis2

    4. **高级功能**:包括MTOM(Message Transmission Optimization Mechanism)和SWA(Soap with Attachments)支持,用于高效传输二进制数据。 5. **部署灵活性**:Axis2支持多种部署方式,如WAR文件、AXIS2.xml配置...

    axis2-1.4.1-bin.zip axis2-1.4.1-war.zip

    Apache Axis2是一个高度可扩展且功能强大的Web服务引擎,它基于Java构建,用于开发、部署和管理SOAP和RESTful Web服务。 1. **Apache Axis2**:Apache Axis2是Apache软件基金会的Web服务项目,它是第二代Axis的升级...

    axis2学习资料

    Axis2是Apache软件基金会开发的一款基于Java的Web服务框架,它是Apache SOAP(Simple Object Access Protocol)项目的下一代产品,专门用于构建高性能、可扩展的Web服务。这个“axis2学习资料”压缩包很可能是包含了...

    axis.war axis2.war

    - **多协议支持**:除了SOAP,Axis2还支持REST、MTOM(Message Transmission Optimization Mechanism)和SwA(SOAP with Attachments)等通信协议。 - **部署方式**:Axis2的WAR文件同样可以在Servlet容器中部署,...

    axis2 for c++ 1.6

    The Apache Axis2/C is a SOAP engine implementation that can be used to provide and consume Web Services. Axis2/C is an effort to implement Axis2 architecture, in C. Please have a look at ...

    axis2-1.4.1

    2. **模块化架构**:Axis2采用了模块化设计,使得用户可以根据需要选择和配置不同的模块,如MTOM(Message Transmission Optimization Mechanism)、SwA(SOAP with Attachments)和REST支持。 3. **性能优化**:...

    最新axis2实例.rar

    Axis2是Apache软件基金会开发的一个Web服务框架,用于构建高性能、高效率的SOAP(Simple Object Access Protocol)服务器和客户端。这个“最新axis2实例.rar”压缩包提供了最新的Axis2实例,便于开发者学习和实践...

    axis2jar包

    5. **MTOM与SwA优化**: MTOM(Message Transmission Optimization Mechanism)和SwA(SOAP with Attachments)是Axis2中用于优化大文件传输的技术。它们能将大文件内容作为链接传递,而不是嵌入到SOAP消息中,从而...

    AXIS2快速学习资料

    在这个名为"AXIS2快速学习资料"的压缩包中,包含两份宝贵的资源:一份是中文的Word文档,标题为"Axis2--Java访问Axis2接口.doc",另一份是英文的PDF,标题为"Axis2--Dev_Web_Services_With_Apache_Axis2.pdf"。...

    axis2c linux下c客户端编程详解

    ./configure --prefix=/zhaojian/axis2c/ --with-axis2=${AXIS2C_HOME}/include/axis2-1.6.0 make make install ``` #### 三、生成C语言客户端代码 生成客户端代码之前,首先需要一个WSDL文件,该文件定义了...

    AXIS2简单例子

    2. 可扩展性:AXIS2支持多种协议和数据格式,包括SOAP、REST、MTOM(Message Transmission Optimization Mechanism)、SwA(Soap with Attachments)等。 3. 易于使用:AXIS2提供了一套直观的API,使得开发和部署Web...

    Java+Axis2调用Web Services 网络接口

    Java和Axis2是开发Web服务客户端的重要工具,用于调用基于SOAP协议的Web服务。本文将深入探讨如何利用Java和Axis2库来实现这一功能,同时结合提供的代码示例进行详细解析。 首先,Web服务是一种通过网络进行通信的...

    axis2-1.7.5-bin.zip

    此外,Axis2支持MTOM(Message Transmission Optimization Mechanism)和SwA(Soap with Attachments),提高处理大型附件的效率。 8. **互操作性**:由于对Web服务标准的全面支持,Axis2与其他Web服务框架(如.NET...

    axis2包.rar

    相比于Axis1,Axis2引入了模块化架构,支持更多的协议和数据格式,如RESTful Web服务、MTOM(Message Transmission Optimization Mechanism)和SwA(Soap with Attachments)。 在实际开发中,使用这些文件可能涉及...

    axis2c-src-1.6.0

    Axis2/C supports both SOAP 1.1 and SOAP 1.2. The soap processing model is built on the AXIOM XML object model. Axis2/C is capable of handling one-way messaging (In-Only) as well as request ...

    axis1,axis2所需架包集合

    Axis1和Axis2是两个非常重要的Java Web服务框架,它们主要用于构建和部署SOAP(Simple Object Access Protocol)服务。本文将详细介绍这两个框架以及与之相关的知识点。 **Axis1** 是Apache软件基金会开发的一个...

    axis2-1.7.4

    4. **模块化架构**:Axis2的核心是一个模块化的架构,允许用户根据需求选择安装和配置不同的模块,如MTOM(Message Transmission Optimization Mechanism)、SwA(Soap with Attachments)等,以优化性能或处理不同...

Global site tag (gtag.js) - Google Analytics