Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

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.

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.

Table 1. 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

Table 2. Child Elements of <connector…​>
Name Cardinality Description

For example:


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
<?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-current.xsd
       http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.4/mule.xsd
       http://www.mulesoft.org/schema/mule/servlet
       http://www.mulesoft.org/schema/mule/servlet/3.4/mule-servlet.xsd">
 
    <servlet:connector name="servletConnector" servletUrl="http://localhost:8888" />
...

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


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

Servlet endpoints accept the same attributes and child elements as HTTP endpoints.

Endpoint

Table 3. Attributes of <endpoint…​>
Name Type Required Default Description

path

string

yes

the servlett path to bind the service to.

Table 4. Child Elements of <endpoint…​>
Name Cardinality Description

Servlet Transport

The Servlet transport allows Mule components to listen for events received via a servlet request.

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.

Table 5. 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

Table 6. Child Elements of <connector…​>
Name Cardinality Description

Inbound endpoint

Table 7. Attributes of <inbound-endpoint…​>
Name Type Required Default Description

path

string

yes

the servlett path to bind the service to.

Table 8. Child Elements of <inbound-endpoint…​>
Name Cardinality Description

Endpoint

Table 9. Attributes of <endpoint…​>
Name Type Required Default Description

path

string

yes

the servlett path to bind the service to.

Table 10. Child Elements of <endpoint…​>
Name Cardinality Description

Transformers

These are transformers specific to this transport. Note that these are added automatically to the Mule registry at start up. When doing automatic transformations these will be included when searching for the correct transformers.

Name Description

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.

http-request-to-input-stream

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

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.