关于 wsdl:mule 项目关闭时显示自定义消息

Display custom message while mule project is shutdown

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
    <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 的代码。
但有时,我的骡子项目因某种原因停止,所以当我输入 http://localhost:8089/services/Echo?wsdl 时,我在浏览器 could not connect to localhost:8089page could not find.

中看到此消息

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


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

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

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