Mule ESB - Using existing servlet in flow

607 views Asked by At

As the title says: (how) is it possible to use an already existing java-servlet (a already developed class in a standart java package) in a mule-flow ? I cannot get it to work, as the documentation for this part is pretty thin.

Thank you for the help!

EDIT: I'm using the mule embedded in my tomcat-webapp. I've defined several endpoints in a mule-config-war.xml, which gets loaded by the tomcat. The optimum would be to use on of those references in that already developed servlet.

An example of servlet-definition from the xml:

<endpoint name="twitter_callbackEndpoint" 
    address="servlet://twitter/callback"
    exchange-pattern="request-response" 
    responseTimeout="30000" >
</endpoint>

So how is it possible to create a plain Java-HTTP-Servlet, reference its @WebServlet-Url to the reference from the xml and use it in a mule-flow?

1

There are 1 answers

0
aled On

To receive a servlet invocation in Mule you need to map the servlet definition in the web.xml file to a dispatcher class from Mule. This is described in the Servlet Transport documenation.

<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>