2017-09-26 9 views
0

내 뮬 (mule) 흐름 - 포스트 http 서비스를 사용하여 데이터베이스에 값을 삽입하려고합니다. 게시물 본문을 입력 스트림에서 json으로 성공적으로 변환 할 수 있습니다. 그러나 테이블에 값을 삽입하려고하면 null 값만 삽입됩니다.노새 흐름에서 json을 구문 분석하는 방법은 무엇입니까?

흐름 :

<?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> 

enter image description here

JSON 입력 :

{ 
    "test" : "success" 
} 
+0

입력 json을 공유 할 수 있습니까? –

+0

@AbhaySingh - { \t "test": "success" } –

답변

1

이보십시오, 나는 당신에 의해 제공되는 입력에 따라, 값 "성공"을 얻을 수있었습니다.

<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/> 
     <flow name="poc_Flow"> 
      <http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP"/> 
      <set-variable variableName="payload" value="#[payload]" mimeType="application/json" doc:name="Variable"/> 
      <json:json-to-object-transformer returnClass="java.lang.Object" doc:name="JSON to Object"/> 
      <logger message="#[payload.test]" level="INFO" doc:name="Logger"/> 
</flow> 
관련 문제