mule http post json数据通过httpendpoint

mule http post json数据通过httpendpoint,mule,mule-component,Mule,Mule Component,使用mule-如何发布json数据以调用我的应用程序url并获得响应。我的json数据如下: { "Reservation" : { "reservation" : { "@id" : "123456789" }, "arrivingDate" : "03-09-2012", "departureDate" : "03-15-2012", "guestName" : "Fred",

使用
mule
-如何发布
json
数据以调用我的应用程序url并获得响应。我的
json
数据如下:

{
    "Reservation" : {
        "reservation" : {
            "@id" : "123456789"
        },
        "arrivingDate" : "03-09-2012",
        "departureDate" : "03-15-2012",
        "guestName" : "Fred",
        "guestLastName" : "Davis",
        "hotelID" : "03",
        "room" : "1001",
        "oceanView" : "true",

    }
}

我想将我的json数据发布到我的应用程序
http://localhost:8080/myapplication/createreservation
通过
MULE HTTP端点
并获得一些应用程序响应。欢迎任何建议。

我想说的第一件事是您的JSON数据无效。。结尾不应该有逗号。。可能缺少一些属性

如果要将数据发布到外部应用程序,可以遵循以下示例:-

<flow name="BestelItems" doc:name="BestelItems">
 <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
 <set-payload doc:name="Set Payload" value="{ &quot;Reservation&quot; : { &quot;reservation&quot; : { &quot;@id&quot; : &quot;123456789&quot; }, &quot;arrivingDate&quot; : &quot;03-09-2012&quot;, &quot;departureDate&quot; : &quot;03-15-2012&quot;, &quot;guestName&quot; : &quot;Fred&quot;, &quot;guestLastName&quot; : &quot;Davis&quot;, &quot;hotelID&quot; : &quot;03&quot;, &quot;room&quot; : &quot;1001&quot;, &quot;oceanView&quot; : &quot;true&quot;}}"/>
 <http:outbound-endpoint exchange-pattern="request-response" method="POST" address="ttp://localhost:8080/myapplication/createreservation" contentType="application/json" doc:name="HTTP"/>
</flow>

但是,如果您想将JSON数据发布到您自己的Mule应用程序中,那么您只需要流具有Http入站端点。。您可以发布来自任何Rest客户机或邮递员的数据

数据将通过rest客户端或Postman应用程序自动进入Mule流,如下所示:-

可以通过以下方式完成:

  • 可以使用与JSON元素相同的字段名创建POJO
  • 创建对象的实例并输入JSON输入
  • 然后使用Mule的Object to JSON transformer指定POJO类的源类
  • 使用HTTP出站端点调用相应的双向HTTP应用程序
  • 收到响应后,将JSON添加到对象转换器,并使用它进一步处理