2

私はミュールESBを初めて使用します。Mule フローを介して公開された残りのエンドポイントの統合テストを実行しようとしています。次のコードは、POST REST エンドポイントにヒットしますが、残りのパラメーターと http メソッド (get、post、delete など) をどのように言えばよいでしょうか。

    MuleClient client = new MuleClient(muleContext);
    String payload = "foo";
    Map<String, Object> properties = new HashMap<String, Object>();
    MuleMessage result = client.send("http://localhost:5000/rest/resource", payload, properties);

渡されるペイロードまたはプロパティ (マップ) に何かを設定する必要がありますか?

4

1 に答える 1

2

ソースコードを調べたところ、次のプロパティで Http メソッドを設定できました。

取得リクエストの例:

    MuleClient client = new MuleClient(muleContext);
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("Content-type", "text/plain");
    properties.put("Accept", "text/plain");
    properties.put("http.method", "GET");

    MuleMessage result = client.send("http://localhost:5000/rest/resource?param1=268", null, properties);

投稿リクエストの例:

    MuleClient client = new MuleClient(muleContext);
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("Content-Type", "application/json");
    properties.put("http.method", "POST");

    String payload = "{...json here...}";

    MuleMessage result = client.send("http://localhost:5000/rest/resource", payload, properties);

それが他の誰かに役立つことを願っています。

于 2014-10-13T11:58:51.850 に答える