0
Dans mon flux de mule - en essayant d'insérer une valeur dans la base de données en utilisant un service http post. Je peux convertir avec succès le corps du message du flux d'entrée en json. Mais en essayant d'insérer la valeur dans la table seule la valeur null est insérée.Comment analyser json dans un flux de mules?
Débit:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="9191" doc:name="HTTP Listener Configuration"/>
<db:mysql-config name="MySQL_Configuration" host="#######" port="####" user="####" password="#####" database="#####" doc:name="MySQL Configuration"/>
<flow name="patient-symptomFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/symptom" allowedMethods="POST" doc:name="HTTP"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<set-variable variableName="payload" value="#[payload]" doc:name="Variable"/>
<byte-array-to-object-transformer doc:name="Byte Array to Object"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
<db:insert config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[insert into test(uuid) values(#[payload.test])]]></db:parameterized-query>
</db:insert>
</flow>
</mule>
Json Entrée:
{
"test" : "success"
}
Pouvez-vous partager votre entrée json? –
@AbhaySingh - { \t "test": "succès" } –