Contact Us 1-800-596-4880

Servlet Transport Reference

The Servlet transport provides integration with a servlet implementation. The implementing servlet does the work of receiving a request, and the Servlet transport then hands off the request to any receivers registered with it. There is no notion of a dispatcher for this connector, as it is triggered by a request and may or may not return a response. You specify the servlet URL as part of the connector configuration and then specify the endpoints just like any other HTTP endpoints.

The Javadoc for this transport can be found here. For more information about using Mule with servlet containers, see Embedding Mule in a Java Application or Webapp.

Connector

Servlet connector is a channel adapter between Mule and a servlet engine. It allows the MuleReceiverServlet to look up components interested in requests it receives via the servlet container.

Attributes of <connector…​>

Name Type Required Default Description

servletUrl

no

The real URL on which the servlet container is bound. If this is not set, the WSDL may not be generated correctly when using CXF bound to a servlet endpoint.

useCachedHttpServletRequest

boolean

no

false

Whether to use a cached http servlet request

No Child Elements of <connector…​>

For example:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:spring="http://www.springframework.org/schema/beans"
       xmlns:servlet="http://www.mulesoft.org/schema/mule/servlet"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
       http://www.mulesoft.org/schema/mule/servlet
       http://www.mulesoft.org/schema/mule/servlet/3.2/mule-servlet.xsd">

    <servlet:connector name="servletConnector" servletUrl="http://localhost:8888" />
...

You can also specify the servlet URL as part of the endpoint:

<servlet:inbound-endpoint path="http://localhost:8888" />

Endpoints

Servlet endpoints accept the same attributes and child elements as HTTP endpoints. For more information, see HTTP Transport Reference.

Http request to parameter map

The <http-request-to-parameter-map> transformer returns a simple Map of the parameters sent with the HTTP Request. If the same parameter is given more than once, only the first value for it will be in the Map.

No Child Elements of <http-request-to-parameter-map…​>

Http request to input stream

The <http-request-to-input-stream> transformer converts an HttpServletRequest into an InputStream.

No Child Elements of <http-request-to-input-stream…​>

Http request to byte array

The <http-request-to-byte-array> transformer converts an HttpServletRequest into an array of bytes by extracting the payload of the request.

No Child Elements of <http-request-to-byte-array…​>