我正在尝试在 Mule 3 中创建一个响应 GET 请求的端点(我认为这是正确的词?)。这个 Mule 应用程序在 Web 容器内的 JavaEE Web 应用程序中运行。
在我的 web.xml 中,我MuleRESTReceiverServlet
定义了一个 servlet,以便它处理 URL 以“/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>
我的<flow>
样子是这样的:
<flow name="myFlow">
<servlet:inbound-endpoint path="category/service" />
<component>
<singleton-object class="com.company.MyComponent" />
</component>
<outbound-endpoint ... />
</flow>
当我向“http://localhost:8080/webappName/rest/category/service”发送 GET 请求时,我希望它能够调用com.company.MyComponent
该类。但相反,我得到了错误:
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.
我尝试将入站端点定义为全局端点,就像错误消息似乎暗示的那样,但我只是得到了同样的错误。
<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>
我还尝试将“路径”属性设置为“rest/category/service”和“/rest/category/service”,但仍然收到相同的错误消息。
我究竟做错了什么?谢谢。