Java Mule ESB-集成测试-REST端点-使用MuleClient

Java Mule ESB-集成测试-REST端点-使用MuleClient,java,rest,mule,esb,mule-component,Java,Rest,Mule,Esb,Mule Component,我不熟悉mule ESB。我正在尝试对通过mule流公开的rest端点进行集成测试。 下面的代码命中了POST REST端点,但我们如何才能说出REST参数和http方法(get、POST或delete等): MuleClient客户端=新的MuleClient(muleContext); 字符串payload=“foo”; 映射属性=新的HashMap(); 多消息结果=客户端。发送(“http://localhost:5000/rest/resource“、有效载荷、财产); 我们是否应该

我不熟悉mule ESB。我正在尝试对通过mule流公开的rest端点进行集成测试。 下面的代码命中了POST REST端点,但我们如何才能说出REST参数和http方法(get、POST或delete等):

MuleClient客户端=新的MuleClient(muleContext);
字符串payload=“foo”;
映射属性=新的HashMap();
多消息结果=客户端。发送(“http://localhost:5000/rest/resource“、有效载荷、财产);

我们是否应该在传递的有效负载或属性(Map)中设置任何内容?

在查看源代码后,我能够使用以下属性设置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客户端=新的MuleClient(muleContext);
映射属性=新的HashMap();
properties.put(“内容类型”、“文本/普通”);
属性。放置(“接受”、“文本/普通”);
properties.put(“http.method”、“GET”);
多消息结果=客户端。发送(“http://localhost:5000/rest/resource?param1=268“,空,属性);
Post请求示例:

    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);
MuleClient客户端=新的MuleClient(muleContext);
映射属性=新的HashMap();
properties.put(“内容类型”、“应用程序/json”);
properties.put(“http.method”、“POST”);
String payload=“{…json here…}”;
多消息结果=客户端。发送(“http://localhost:5000/rest/resource“、有效载荷、财产);
希望它能帮助别人

    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);