<servlet>
<servlet-name>muleServlet</servlet-name>
<servlet-class>org.mule.transport.servlet.MuleReceiverServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>muleServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
Servlet Transport Reference
Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version. |
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 FTP endpoints.
Access a Servlet Endpoint
You can define a servlet in a web application that connects the request from the client to a Mule servlet endpoint.
For example in web.xml:
Access the Servlet endpoint using an URL with the following pattern:
http://host:port/webapp-contextname/servlet-mapping-URL/path
Where:
-
host and port - URL and port for where you access the Application Server
-
webapp-contextname - The context name of the web application where Mule ESB is deployed
-
_servlet-name _- Mule servlet URL defined in web.xml
-
path - Path attribute in the endpoint
Javadoc
The Javadoc for this transport is:
For more information about using Mule with servlet containers, see Embedding Mule in a Java Application or Webapp.
Reference
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.
Name | Description |
---|---|
servletUrl |
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. Type: string |
useCachedHttpServletRequest |
Whether to use a cached http servlet request. Type: boolean |
No Child Elements of <connector…>
For example:
<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.6/mule.xsd
http://www.mulesoft.org/schema/mule/servlet
http://www.mulesoft.org/schema/mule/servlet/current/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" />
Servlet endpoints accept the same attributes and child elements as HTTP endpoints. For more information, see FTP Transport Reference.
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.
Name | Description |
---|---|
servletUrl |
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. Type: string |
useCachedHttpServletRequest |
Whether to use a cached http servlet request. Type: boolean |
No Child Elements of <connector…>
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. |