0

It seems like using Servlet end point in Mule is simple, but I get mesh up in some things with lack of understanding. To get a clearer view, can I have a sample code with a servlet endpoint and how call it from Java application.

This is my Mule-config.XML.

<flow name="servletFlow1" doc:name="servletFlow1">
  <servlet:inbound-endpoint path="name" responseTimeout="10000"/>
  <echo-component doc:name="Echo"/>
</flow>

Questions:

  1. How could send and get request in a browser to this application.
  2. How to connect to the this application from Java swing, if this application deployed in Mule Standalone server.
Jeevanantham
  • 984
  • 3
  • 19
  • 48

1 Answers1

0

Answers:

  1. Assuming your web application listens over HTTP, call http://localhost:{http.port}/{web-app-context-path}/{mule-servlet-context-path}/name. Replace the values in { } with what is relevant to you.
  2. If you deploy in Mule standalone, better not use the Servlet transport and prefer the HTTP one. To send HTTP requests from a Java application, one good option is to use the Apache HTTP Client.
David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • Hi @david Dossot, for question 1 : I m running that application in mule studio itself, as i have seen many of ur commnets that server connector is not mandatory, so how can i identify that this running which url and port, and could i find the {web-app-context-path}/{mule-servlet-context-path}.. plz assit, for ex: for the mule-config.xml how could i frame the context path.. – Jeevanantham Feb 20 '13 at 04:07
  • Can i have any sample mule config.xml regarding this, to get better understanding, bcz when i use http endpoint it went smooth, i have request in "http://localhost:8080/?name=xyz&job=zzz".. but when i change the endpoint to servlet, i couldn't understand well or could send request like in http endpoin – Jeevanantham Feb 20 '13 at 04:12
  • If you want to run a JavaEE web application from Studio, you need to install a plug-in like https://code.google.com/p/run-jetty-run/ to allow it. Typically the project name will be used as {web-app-context-path}. What you would have put in web.xml would give you {mule-servlet-context-path}. Also read http://stackoverflow.com/a/14859119/387927 for more info. – David Dossot Feb 20 '13 at 16:57
  • I am not running JavaEE app in studio, my question is, while run the simple "hello world" mule application in studio / mule runtime, with Servlet end points, how can i form the URL pattern for that, to send a input data like in http endpoints. – Jeevanantham Feb 21 '13 at 12:15
  • I answered this question in my response. – David Dossot Feb 21 '13 at 16:07
  • As per the response, i form the URL pattern with project name and servlet endpoint name, it is "http://localhost:8081/servletSample/bkg", in servlet connecter "http://localhost:8081" is provided. but when i hit this URL from browser "Unable to connect" problem occurred, so where could be the problem, but the project is started well in mule studio and couldn't access it. – Jeevanantham Feb 22 '13 at 04:11
  • ,i additon to above comment, in following reference [link-Servlet endpoint PATH](http://www.mulesoft.org/documentation/display/current/Servlet+Transport+Reference), it mentioned that, we can provide url in path itself like "" but while run the project in studio in throws error for this config.. – Jeevanantham Feb 22 '13 at 04:26
  • Do you use the Jetty plugin to start your project? As I explained you have to start the project as a web-app not a mule-app. – David Dossot Feb 22 '13 at 17:43