简体   繁体   English

在MULE ESB中调用REST

[英]REST call in MULE ESB

Rest call is implemented in Java. Rest调用是用Java实现的。 same thing i want to implement in mule, 同样的事情,我想在骡​​子,
Java code is below: Java代码如下:

URL url = new URL(RestUriConstants.BUSINESS_PROCESS_BASE + businessProcessName);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Accept","application/json");
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream()); 
writer.write(data);
writer.flush();

in mule i'm sending two things 在骡子我发送两件事
1. URL 1.网址
2. pay load 2.有偿负担

the json is like below: json如下:
{"url":" http://mysystem.com:8080/rest/processData ","param":{"claimNo":"9","status":"open", "customerName":"Rajesh"}} {“url”:“ http://mysystem.com:8080/rest/processData ”,“param”:{“claimNo”:“9”,“status”:“open”,“customerName”:“Rajesh”} }

how can i pass that url dynamically, as well as i need to pass param value into the rest call.. 我怎样才能动态传递该url,以及我需要将param值传递给其余的调用..

---UPDATE---- ---更新----

payload value is like 有效载荷值就像
"action=start&params={'input':#[json:param]}&createTask=false&parts=all" “动作=起始&PARAMS = { '输入':#[JSON:PARAM]}&的CreateTask =假零件=所有”

example: 例:

<set-payload value="action=start&params={'input':#[json:param]}&createTask=false&parts=all"/>

but it is giving error. 但它给出了错误。

thanks. 谢谢。

To do rest calls with a dynamic url in Mule, you just need to set the json as payload first, and then 要在Mule中使用动态URL进行休息调用,您只需先将json设置为有效负载,然后再进行

<http:outbound-endpoint exchange-pattern="request-response" address="http://#[url]" method="POST" />

with variable url defining the url. 使用可变url定​​义url。

If your payload is the above json string, you can do 如果你的有效载荷是上面的json字符串,你可以这样做

<set-variable variableName="url" value="#[json:url]"/>

and

<set-payload value="#[json:param]"/>

before the outbound. 在出境前。 Note that in this case you have to strip the "http://" url prefix in the outbound like this: 请注意,在这种情况下,您必须在出站中删除“http://”url前缀,如下所示:

address="http://#[url.substring(7)]"

Hope this gets you started, your question is a bit unclear. 希望这能让你开始,你的问题有点不清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM