2

Mule HTTP 受信エンドポイントを次のように定義しました。

<flow name="jfeed_fill_data">
    <http:inbound-endpoint address="http://localhost:1212/jcore/insert/feed/">
    </http:inbound-endpoint>
<component class="main.java.com.joshlabs.jcore.Feed"/>
</flow>

これで、このサービスは正常に機能します。

しかし、 「http://localhost:1212/jcore/insert/feedasdasdAwes/」のような Deformed URL を入力すると、MULE から次のメッセージが表示されます。

Cannot bind to address "http://localhost:1212/jcore/insert/feedasdasdAwes/"
No component registered on that endpoint

私の質問は次のとおりです。上記のデフォルトのメッセージを自分のものに変更するにはどうすればよいですか?

注:実際には、JSON文字列をエラーメッセージとして返したかったのです。何かのようなもの :

{
  Exception: "Invalid URL"
}

そして、可能であれば、「上記の場合、MULE はHTTP 404 : Not Foundエラーをスローできますか?」..??

4

1 に答える 1

2

エンドポイントにすべてのサブパスを受け入れさせ、メッセージ ルーティングで間違ったものを処理するだけです。

<flow name="jfeed_fill_data">
    <http:inbound-endpoint address="http://localhost:1212" />
    <choice>
        <when evaluator="header" expression="INBOUND:http.request.path=/jcore/insert/feed/">
            <component class="main.java.com.joshlabs.jcore.Feed"/>
        </when>
        <otherwise>
            <message-properties-transformer>
                <add-message-property key="http.status" value="404"/>
            </message-properties-transformer>
            <expression-transformer>
                <return-argument evaluator="string" expression="{Exception: &quot;Invalid URL&quot;}"/>
            </expression-transformer>
        </otherwise>
    </choice>
</flow>
于 2011-11-17T06:30:15.620 に答える