我想从业务流程服务器的BPMN REST向ESB的代理服务发送消息,但是当我调用某个进程时,会抛出异常。
TID: [-1234] [] [2017-08-30 18:22:15,504] ERROR {org.wso2.carbon.bpmn.extensions.rest.RESTTask} - Failed to execute POST http://localhost:8280/services/bpmnProxy within task servicetask1:REST Task in process instance 7501 {org.wso2.carbon.bpmn.extensions.rest.RESTTask}
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('C' (code 67)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: java.io.StringReader@5dbc3edb; line: 1, column: 2]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1369)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:532)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:453)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleUnexpectedValue(ReaderBasedJsonParser.java:1386)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:669)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:2926)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2873)
at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:1750)
at org.wso2.carbon.bpmn.core.types.datatypes.json.JSONUtils.parse(JSONUtils.java:42)
at org.wso2.carbon.bpmn.extensions.rest.RESTTask.execute(RESTTask.java:210)
at org.activiti.engine.impl.delegate.JavaDelegateInvocation.invoke(JavaDelegateInvocation.java:34)
TID: [-1234] [] [2017-08-30 18:22:15,525] ERROR {org.wso2.carbon.bpmn.rest.common.provider.ExceptionMapper.BPMNExceptionHandler} - Activiti Exception Occured {org.wso2.carbon.bpmn.rest.common.provider.ExceptionMapper.BPMNExceptionHandler}
org.activiti.engine.delegate.BpmnError: No catching boundary event found for error with errorCode 'REST_CLIENT_INVOKE_ERROR', neither in same process nor in parent process (errorCode='REST_CLIENT_INVOKE_ERROR') (errorCode='REST_CLIENT_INVOKE_ERROR')
at org.activiti.engine.impl.bpmn.helper.ErrorPropagation.propagateError(ErrorPropagation.java:82)
at org.activiti.engine.impl.bpmn.helper.ErrorPropagation.propagateError(ErrorPropagation.java:60)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.execute(ClassDelegate.java:160)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:644)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:637)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
我做错了什么?
通话方案: 客户 - > esb的代理服务 - >业务流程 - >调用Rest API-> esb的代理服务
1. esb->业务流程的代理服务:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="processProxy" startOnLoad="true" statistics="disable" trace="disable" transports="http,https">
<target>
<inSequence>
<payloadFactory media-type="json">
<format>
{
"processDefinitionKey":"myProcess",
"tenantId": "-1234",
"variables": [
{
"name":"Name",
"value":"$1"
}]
}
</format>
<args>
<arg evaluator="xml" expression="//req/name/text()"/>
</args>
</payloadFactory>
<header expression="fn:concat('Basic ', base64Encode('admin:admin'))" name="Authorization" scope="transport"/>
<header name="Content-Type" scope="transport" value="application/json"/>
<header name="Accept" scope="transport" value="application/json"/>
<log level="full"/>
<send>
<endpoint>
<http method="POST"
uri-template="https://localhost:9445/bpmn/runtime/process-instances"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
</outSequence>
<faultSequence/>
</target>
<description/>
</proxy>
2.Business process-&gt; invoke Rest API:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="myProcess" name="My process" isExecutable="true">
<startEvent id="startevent1" name="Start">
<extensionElements>
<activiti:formProperty id="vName" name="vName" type="string" variable="vName" required="true"></activiti:formProperty>
</extensionElements>
</startEvent>
<serviceTask id="servicetask1" name="REST Task" activiti:class="org.wso2.carbon.bpmn.extensions.rest.RESTTask" activiti:extensionId="org.wso2.developerstudio.bpmn.extensions.restTask.RESTTask">
<extensionElements>
<activiti:field name="serviceURL">
<activiti:string>http://localhost:8280/services/bpmnProxy</activiti:string>
</activiti:field>
<activiti:field name="method">
<activiti:string>POST</activiti:string>
</activiti:field>
<activiti:field name="input">
<activiti:expression>{
"Name":"${vName}"
}</activiti:expression>
</activiti:field>
<activiti:field name="headers">
<activiti:string>Content-Type:application/json</activiti:string>
</activiti:field>
</extensionElements>
</serviceTask>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
<sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
</process>
</definitions>
3.Invoke Rest API-&gt; esb的代理服务
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="bpmnProxy" startOnLoad="true" statistics="disable" trace="disable" transports="http,https">
<target>
<inSequence>
<property expression="json-eval($.Name)" name="vName" scope="default" type="STRING"/>
<payloadFactory media-type="xml">
<format>
<req>
<name>$1</name>
</req>
</format>
<args>
<arg evaluator="xml" expression="get-property('vName')"/>
</args>
</payloadFactory>
<property name="HTTP_METHOD" scope="axis2" type="STRING" value="POST"/>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<send>
<endpoint>
<address uri="http://192.168.18.1:8740"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<payloadFactory media-type="json">
<format>
{
"result":"success"
}
</format>
<args/>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<send/>
</outSequence>
<faultSequence/>
</target>
<description/>
</proxy>
答案 0 :(得分:0)
我找到了原因。
在源代码org.wso2.carbon.bpmn.extensions.rest类RESTTask中,标题试图解析为JSON对象
if (headers != null) {
String headerContent = headers.getValue(execution).toString();
jsonHeaders = JSONUtils.parse(headerContent);
}
但我找到的所有示例,标题都以字符串形式传递:
"Content-Type:application/json, ....."
使标题JSON对象和所有工作
{"Accept":"application/json","Content-Type":"application/json"}