2016-10-07 1 views
0

변환 메시지 커넥터에 입력으로 응답 메시지 또는 비즈니스 오류 메시지를 수신 할 수있는 뮬 워크 플로우가 있습니다. 이 문자열 오브젝트로 변환 메시지 커넥터에서 이동할 때Mule에서 반환되는 다른 유형의 메시지로 인해 유형 불일치 오류가 반환되었습니다.

은이 오류 안타

ERROR 2016-10-07 18:08:40,187 [[userprocess].userprocess-httpListenerConfig.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy: 
******************************************************************************** 
Message    : Exception while executing: 
    }) when ((payload[0].userResponse != null and payload[0].userResponse.category == "SUCCESS")) and 
         ^
Type mismatch 
    found :name, :string 
    required :name, :object 
Type     : com.mulesoft.weave.mule.exception.WeaveExecutionException 
Code     : MULE_ERROR--2 
******************************************************************************** 
Exception stack is: 
1. Type mismatch 
    found :name, :string 
    required :name, :object (com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchException) 
    com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchNode:65 (null) 
2. Exception while executing: 
    }) when ((payload[0].userResponse != null and payload[0].userResponse.category == "SUCCESS")) and 
         ^
Type mismatch 
    found :name, :string 
    required :name, :object (com.mulesoft.weave.mule.exception.WeaveExecutionException) 
    com.mulesoft.weave.mule.WeaveMessageProcessor$WeaveOutputHandler:166 (null) 
******************************************************************************** 
Root Exception stack trace: 
com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchException: Type mismatch 
    found :name, :string 
    required :name, :object 

I 메시지가 처리 될 때 다른 필드에 기초하여 논리를 수행 메시지를 변환 때문이라고 생각을 그럼 이 문제를 해결하려면 비즈니스 오류 메시지가 반환되면 응답 메시지 논리를 무시하고 그 반대의 경우도 마찬가지입니다.

어떻게하면됩니까?

Dataweave 코드 (XML을 JSON은) :

%dw 1.0 
%output application/xml 
--- 
{ 
    (Data: { 
     userId: flowVars.queryParams.userId, 
     Message: "User created successfully" 
    }) when (payload[0].userResponse.category == "SUCCESS") and 
      (payload[1].userResponse.category == "SUCCESS"),    

    (Exception: { 
     userId: flowVars.queryParams.userId, 
     Message: payload[1].exception.message 
     }) when (payload.exception?) and 
       (payload[1].exception.action == "createUser") and 
       (payload[0].exception.code != "-1"), 
    (Exception: { 
     userId: flowVars.queryParams.userId, 
     Message: payload[0].exception.message 
     }) when (payload.exception?) and 
      (payload[0].exception.action == "amendUser") and 
      (payload[1].exception.replyStatus.code != "-1"), 
} 

답변

0

당신은 사용할 수있을 때/그렇지 않으면이 상황이다. 가까운 사이에 괄호 대신 {}을 사용하십시오. 의 행을 따라 뭔가 :

%dw 1.0 
%input payload application/json 
%output application/xml 
--- 
{ 
    Data: { 
     userId: flowVars.queryParams.userId, 
     Message: "User created successfully" 
    } 
} 
when (payload[0].userResponse.category == "SUCCESS") and 
    (payload[1].userResponse.category == "SUCCESS")) 
otherwise 
{ 
    Exception: { 
     userId: flowVars.queryParams.userId, 
     Message: payload[1].exception.message 
    } 
} 
+0

안녕. 위의 코드로 잘라내어 붙여 넣기해도 동일한 오류가 발생합니다. 또한 위의 데이터 위브 코드를 업데이트하기 위해 세 번째 규칙을 추가해야합니다. 감사합니다 – user3165854

+0

당신의 페이로드는 어떻게 생겼습니까? @ user3165854 –

+0

안녕하세요. 괜찮아. 나는이 객체 검사가 나를 위해 일한다는 것을 발견했다. "(payload [0] .userResponse?) and ...". userResponse 객체가 있는지 확인합니다. – user3165854