2012-02-13 42 views
2

我是想以此爲榜樣如何加載騾子XML配置

http://www.mulesoft.org/documentation/display/MULE3USER/Building+Web+Services+with+CXF

上的遺留項目,所以後來我創建一個主類與啓動春天像這樣一個主要方法(或我認爲這是如何做到這一點)

XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(
      "mule-config.xml")); 

但我然後telnet到我有我的web服務的端口,它不工作!

  1. 是不是應該開始它自己的web容器/服務器或做我需要部署到Tomcat或一些應用服務器,使這項工作
  2. 如果答案#1需要部署,爲什麼會出現在他們的例子中指定的絕對url就像它會爲你啓動一個?

如何讓這個工作?

這裏是我的xml ..

<flow name="helloService"> 
    <http:inbound-endpoint address="http://localhost:63081/enrollment" exchange-pattern="request-response"> 
     <cxf:jaxws-service serviceClass="com.ifp.esb.integration.ingest.EnrollmentWS"/> 
    </http:inbound-endpoint> 
    <component> 
     <spring-object bean="enrollmentBean" /> 
    </component> 
</flow> 

回答

5

您需要使用騾子特定Spring配置裝載機:

SpringXmlConfigurationBuilder builder = new SpringXmlConfigurationBuilder("mule-config.xml"); 
MuleContextFactory muleContextFactory = new DefaultMuleContextFactory(); 
MuleContext muleContext = muleContextFactory.createMuleContext(builder); 
muleContext.start(); 
0

您可以使用web應用程序啓動騾子背景了。看到它被標記爲在啓動時加載。

下面是一個web.xml的例子

<web-app 
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd" 
version="2.4"> 
<context-param> 
    <param-name>org.mule.config</param-name> 
    <param-value> 
     mule-config.xml, 
     mule-config2.xml, 
      ... 
     mule-config99.xml 
    </param-value> 
</context-param> 

<listener> 
    <listener-class>org.mule.config.builders.MuleXmlBuilderContextListener</listener-class> 
</listener> 

<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>/muleservlet/*</url-pattern> 
</servlet-mapping> 
</web-app>