在mule项目关闭时显示自定义消息

时间:2013-05-12 11:39:46

标签: wsdl cxf mule

在MULE CE 3.3.0中,我有这个配置XML文件(我在下面复制了它)

    <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.3.0"
    xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">


    <configuration>
        <expression-language>
            <global-functions>
                def parseIp(fullIp) {
                return
                fullIp.substring(fullIp.indexOf('/') + 1, fullIp.indexOf(':'))
                }
        </global-functions>
        </expression-language>
    </configuration>

    <cxf:configuration enableMuleSoapHeaders="false"
        doc:name="CXF Configuration" />
    <flow name="soapservice" doc:name="soapservice">

        <http:inbound-endpoint exchange-pattern="request-response"
            address="http://localhost:8089/services/Echo">
            <cxf:proxy-service service="Weather" payload="envelope"
                wsdlLocation="classpath:myWS.wsdl"

                namespace="http://ws.cdyne.com/WeatherWS/">
                <cxf:inInterceptors>
                    <spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
                </cxf:inInterceptors>
                <cxf:outInterceptors>
                    <spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
                </cxf:outInterceptors>
            </cxf:proxy-service>
        </http:inbound-endpoint>
        <copy-properties propertyName="SOAPAction" />
        <set-variable variableName="remoteClientAddress"
            value="#[parseIp(message.inboundProperties['MULE_REMOTE_CLIENT_ADDRESS'])]" />

        <component doc:name="classTest" class="com.subu.mule.IpClient" />
        <http:outbound-endpoint address="http://wsf.cdyne.com/WeatherWS/Weather.asmx"
            encoding="UTF-8" responseTimeout="1000000" exchange-pattern="request-response">
            <cxf:proxy-client payload="envelope">
                <cxf:inInterceptors>
                    <spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />
                </cxf:inInterceptors>
                <cxf:outInterceptors>
                    <spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
                </cxf:outInterceptors>
            </cxf:proxy-client>
        </http:outbound-endpoint>


    </flow>
</mule>

之后我在浏览器中运行我的mule项目,我输入http://localhost:8089/services/Echo?wsdl然后我可以看到wsdl的代码。 但有时,我的mule项目由于某种原因而停止,所以当我输入http://localhost:8089/services/Echo?wsdl时,我在浏览器中看到此消息could not connect to localhost:8089 page could not find

我想控制此消息,实际上当我的服务(mule项目)关闭时,我发布了我设置它的自定义消息。例如,我在浏览器中向客户显示此消息:此时服务已关闭,请稍后再试!!!!

1 个答案:

答案 0 :(得分:1)

在生产环境中,可以通过在后端服务器关闭时放置一个知道该做什么的前端(即负载均衡器)来实现。

相反,当您尝试直接连接到后端(即您在工作室中运行的项目)并且此后端已关闭时,请由客户端(即您的浏览器)显示与404 http错误代码关联的错误消息。

您可以找到有关404 http状态如何工作的信息here