Home Web How to Configure Axis2 to use HTTPS or HTTP or both HTTP...

How to Configure Axis2 to use HTTPS or HTTP or both HTTP and HTTPS

300
1
SHARE

When we deploy a webservice application in servlet container like Tomcat or WebSphere or WebLogic or may be a Jboss server. The default protocol is working for HTTP. Now when it comes to HTTPS,(after configuring the server container to accept HTTPS request) ,web service will stop responding to HTTPS request but the rest part or web application would be working. The reason behind it is HTTPS request will be reaching to servlet container but will not be able to invoke or connect to webservice. Axisservlet configured in web.xml will not be able to find out the right port. Ahhhh which port???

Well! HTTPS port is different from HTTP port. What are the configurations?

There are two configuration that you need to do. They are below.

  1. org.apache.axis2.transport.http.AxisServlet must be registered and mapped as a servlet in 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>

 

  1. Configuring axis2.xml to enable HTTPS or HTTP or both.

We need to declare one or more org.apache.axis2.transport.http.AxisServletListener instances as transport receivers in axis2.xml. If only a single protocol is used, no further configuration is required. For example, if only HTTP is used, the following declaration must be present in axis2.xml:

<transportReceiver name=”https” class=”org.apache.axis2.transport.http.AxisServletListener”/>

OR

<transportReceiver name=”http” class=”org.apache.axis2.transport.http.AxisServletListener”/>

If both HTTP and HTTPS are used, then things become a bit more complicated. We need to put the port informations as well so that both HTTP and HTTPS ports are recognised by AxisServlet.

<transportReceiver name=”http” class=”org.apache.axis2.transport.http.AxisServletListener”>

    <parameter name=”port”>8080</parameter>

</transportReceiver>

<transportReceiver name=”https” class=”org.apache.axis2.transport.http.AxisServletListener”>

    <parameter name=”port”>8443</parameter>

</transportReceiver>

When we deploy a webservice application in servlet container like Tomcat or WebSphere or WebLogic or may be a Jboss server. The default protocol is working for HTTP. Now when it comes to HTTPS,(after configuring the server container to accept HTTPS request) ,web service will stop responding to HTTPS request but the rest part or web application would be working. The reason behind it is HTTPS request will be reaching to servlet container but will not be able to invoke or connect to webservice. Axisservlet configured in web.xml will not be able to find out the right port. Ahhhh which port???

 

Well! HTTPS port is different from HTTP port. What are the configurations?

There are two configuration that you need to do. They are below.

  1. org.apache.axis2.transport.http.AxisServlet must be registered and mapped as a servlet in 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>

 

  1. Configuring axis2.xml to enable HTTPS or HTTP or both.

We need to declare one or more org.apache.axis2.transport.http.AxisServletListener instances as transport receivers in axis2.xml. If only a single protocol is used, no further configuration is required. For example, if only HTTP is used, the following declaration must be present in axis2.xml:

<transportReceiver name=”https” class=”org.apache.axis2.transport.http.AxisServletListener”/>

OR

<transportReceiver name=”http” class=”org.apache.axis2.transport.http.AxisServletListener”/>

If both HTTP and HTTPS are used, then things become a bit more complicated. We need to put the port informations as well so that both HTTP and HTTPS ports are recognised by AxisServlet.

<transportReceiver name=”http” class=”org.apache.axis2.transport.http.AxisServletListener”>

    <parameter name=”port”>8080</parameter>

</transportReceiver>

<transportReceiver name=”https” class=”org.apache.axis2.transport.http.AxisServletListener”>

    <parameter name=”port”>8443</parameter>

</transportReceiver>

SHARE
  • Hi there. Do you realize that this post has its info duplicated? Search for teh first line, “When we deploy a webservice application in servlet container like Tomcat”, and you will see that it appears twice, and all the content is repeated after the second one. If you correct that, feel free to delete this comment.

    Thanks for the post, of course.