Reputation: 35351
I'm trying to create an endpoint (I think that's the right word?) in Mule 3 that responds to GET requests. This Mule application runs within a JavaEE web app within a web container.
In my web.xml, I have a MuleRESTReceiverServlet
servlet defined so that it handles all requests whose URLs begin with "/rest/":
<web-app>
<listener>
<listener-class>org.mule.config.builders.MuleXmlBuilderContextListener</listener-class>
</listener>
<servlet>
<servlet-name>muleRESTServlet</servlet-name>
<servlet-class>org.mule.transport.servlet.MuleRESTReceiverServlet</servlet-class>
<load-on-startup />
</servlet>
<servlet-mapping>
<servlet-name>muleRESTServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
My <flow>
looks like this:
<flow name="myFlow">
<servlet:inbound-endpoint path="category/service" />
<component>
<singleton-object class="com.company.MyComponent" />
</component>
<outbound-endpoint ... />
</flow>
When I sent a GET request to "http://localhost:8080/webappName/rest/category/service", I expect it to invoke the com.company.MyComponent
class. But instead, I get the error:
org.mule.api.endpoint.MalformedEndpointException: The endpoint "service" is malformed and cannot be parsed. If this is the name of a global endpoint, check the name is correct, that the endpoint exists, and that you are using the correct configuration (eg the "ref" attribute). Note that names on inbound and outbound endpoints cannot be used to send or receive messages; use a named global endpoint instead.
I tried defining the inbound endpoint as a global endpoint like the error message seems to suggest, but I just get back the same error.
<servlet:endpoint name="myEndpoint" path="category/service" />
...
<flow name="myFlow">
<inbound-endpoint ref="myEndpoint" />
<component>
<singleton-object class="com.company.MyComponent" />
</component>
<outbound-endpoint ... />
</flow>
I've also tried setting the "path" attribute to "rest/category/service" and "/rest/category/service", but still got the same error message.
What am I doing wrong? Thanks.
Upvotes: 1
Views: 4062
Reputation: 33413
The org.mule.transport.servlet.MuleRESTReceiverServlet
works with a very specific path convention that allows you to directly query an existing Mule endpoint by name or path. Read the JavaDoc here.
In your case, to use servlet:inbound-endpoint
, you need to use the org.mule.transport.servlet.MuleReceiverServlet
.
Upvotes: 2