Configuring and Enabling Transports
There are some methods to configure and enable transports in WSO2 Carbon or any Carbon-based solution.
- #Using the axis2.xml file
- #Using the WSO2 Carbon Management Console
- #Configuring Servlet Transports in the Standalone Mode Using the transports.xml File
- #Configuring Transports at Service Level
Note
Globally enabled and configured transports will effect all the services deployed on the Carbon instance.
Using the axis2.xml File
WSO2 Carbon and all Carbon-based products are shipped with a configuration file named axis2.xml. This XML configuration file can be found at $CARBON_HOME{color}repository\conf directory. This is similar to the axis2.xml file that ships with "Apache Axis2" and "Apache Synapse." It contains the global configuration for WSO2 Carbon and the Carbon-based products. The axis2.xml configuration generally includes configuration details for modules, phases, handlers, global configuration parameters and transports. The elements <transportReceiver> and <transportSender> are used to configure transport listeners and senders respectively. In the axis2.xml file that comes with WSO2 Carbon or any Carbon-based product, some transports are already configured and enabled by default, including the HTTP and HTTPS transports.
The HTTP transport receiver configuration is something similar to the following as mentioned in the axis2.xml file.
<transportReceiver name="http" class="org.wso2.carbon.core.transports.http.HttpTransportListener"> <!-- Uncomment the following if you are deploying this within an application server. You need to specify the HTTP port of the application server --> <parameter name="port">9763</parameter> <!-- Uncomment the following to enable Apache2 mod_proxy. The port on the Apache server is 80 in this case. --> <!--<parameter name="proxyPort">80</parameter>--> </transportReceiver>
<transportResiever> attributes and elements:
- name - A mandatory attribute which indicates a unique name for the transport receiver.
- class - A mandatory attribute which indicates the transport receiver implementation class.
- parameters - Configuration parameters for the transport receiver. It should be included as child elements of the <transportReceiver> element.
In the above example, the parameter named "port" for the HTTP transport receiver was defined.
Similarly <transportSender> elements can be used to configure and enable transport senders in WSO2 Carbon. Given below is the HTTP transport sender configuration that comes with WSO2 Carbon by default along with other transports as mentioned in the axis2.xml file. It contains three parameters.
<transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"> <parameter name="PROTOCOL">HTTP/1.1</parameter> <parameter name="Transfer-Encoding">chunked</parameter> <parameter name="OmitSOAP12Action">true</parameter> </transportSender>
Note
The axis2.xml file will be loaded to memory only during server startup. Therefore any changes made to the file while the server is up and running will not be applied until the server is restarted.
Note
Simply having <transportReceiver> and <transportSender> elements in the axis2.xml file causes those transports to be loaded and activated during server startup. Therefore any dependency JARs required by those transport implementations must be included in the server classpath to prevent the server from running into exceptions at startup. In addition to that, an inaccurate transport configuration (for example, a wrong parameter value) might cause the transport to be not enabled properly.
Using the WSO2 Carbon Management Console
As an alternative to the traditional axis2.xml file-based configuration method, one might use the WSO2 Carbon Management Console to manage transport receivers and senders.
Note
Earlier versions of WSO2 Carbon did not enable the user to manage transport senders through the management console. This functionality was first introduced in WSO2 Carbon 2.0.
Carbon Management Console loads transport configurations from the embedded registry and any changes made to the configurations through the UI will also be saved back into the registry.
To manage transports from the Data Services Server Management Console, click on "Transports" under the "Configure" menu to the left of the screen. From there you can configure, enable or disable individual transport receivers and senders. See more information about Transport Management in Configuring Transports.
As of WSO2 Carbon version 2.0 and later, the management console also allows adding new parameters to the transport configurations. Also note that Carbon Management Console does not allow the user to disable HTTP, HTTPS transports. This is because those transports are required by the management console and all the related administrative services.
When a transport is enabled from the management console, its configuration will be saved in the registry and will be loaded automatically during the next server startup.
Note
Transport configurations specified in axis2.xml get higher priority over configurations stored in the registry. Therefore if the same transport is enabled in axis2.xml as well as in the registry, transport configuration in axis2.xml will be loaded and activated.
This method of configuration is mainly intended for relatively novice users. However, it is very useful even for advanced users because it enables one to try out different transport settings without having to restart the server many times.
Configuring Servlet Transports in the Standalone Mode Using the transports.xml File
In addition to the two methods discussed above, there is a third method to globally configure transport receivers in Carbon, which works only when Carbon is running in the standalone mode (in other words, no external servelet container is being used to deploy Carbon). By default, WSO2 Carbon and all Carbon-based products run in the standalone mode. Hence, it is important that users be aware of this configuration method.
When Carbon is running in the standalone mode, one could use the $CARBON_HOME\repository\conf\mgt-transports.xml file to specify transport receiver configurations. By default, you will find the HTTP and HTTPS transports. mgt-transports.xml file is similar to the syntax used in the axis2.xml file. One difference is the <transport> element replacing <transportReceiver> element. The default HTTP receiver configuration specified in the mgt-transports.xml file is given below.
<transport name="http" class="org.wso2.carbon.server.transports.http.HttpTransport"> <parameter name="protocol">HTTP_11_NIO</parameter> <parameter name="port">${Ports.ServletTransports.HTTP}</parameter> <!-- Uncomment the following to enable Apache2 mod_proxy. The port on the Apache server is 80 in this case. --> <!--<parameter name="proxyPort">80</parameter>--> <!--<parameter name="address">127.0.0.1</parameter>--> <parameter name="maxHttpHeaderSize">8192</parameter> <parameter name="acceptorThreadCount">2</parameter> <parameter name="maxThreads">250</parameter> <parameter name="minSpareThreads">50</parameter> <parameter name="disableUploadTimeout">false</parameter> <parameter name="connectionUploadTimeout">120000</parameter> <parameter name="maxKeepAliveRequests">200</parameter> <parameter name="acceptCount">200</parameter> <parameter name="server">WSO2 Carbon Server</parameter> <parameter name="compression">on</parameter> <parameter name="compressionMinSize">2048</parameter> <parameter name="noCompressionUserAgents">gozilla, traviata</parameter> <parameter name="compressableMimeType"> text/html,text/javascript,application/x-javascript,application/javascript,application/xml,text/css,application/xslt+xml,text/xsl,image/gif,image/jpg,image/jpeg </parameter> </transport>
There is a fundamental difference between transports configured in axis2.xml and transports configured in mgt-transports.xml. Transport receivers configured in mgt-transports.xml will be loaded through a special "Transport Manager" implementation in Carbon. Therefore, the classes specified in the <transport> element must implement the interface org.wso2.carbon.server.transports.Transport. Currently only the default servlet transports of Carbon can be configured from the mgt-transports.xml file.
Note
For more details on config parameters, see http://tomcat.apache.org/tomcat-7.0-doc/config/http.html
Configuring Transports at Service Level
WSO2 Carbon and Carbon-based products enable the user to configure transports at service level. Transports configured at the service level will effect individual services and not all the services deployed on the Carbon instance. Some transport implementations such as JMS and FIX mandate configuring certain transport parameters at service level.
Service level transport configuration is performed by editing the service.xml file associated with each service. When dealing with Proxy Services (for example in WSO2 ESB), using the Carbon's proxyadmin component, service level transport parameters should be specified in the Proxy Service configuration by using the provided Proxy Service management tools in the Carbon management console.