我有一个示例,使用api调用代理服务。在代理服务中,我称之为端点。端点返回json数据,数据是组合。然后我使用payloadFactory Meditor分析那一个。但程序错误!
样品:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="getRTDataHistoryZipProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full" separator=",">
<property name="method" expression="get-property('transport','method')"/>
<property name="kksCodes" expression="get-property('transport','kksCodes')"/>
<property name="uri.var.startTime"
expression="get-property('transport','startTime')"/>
<property name="uri.var.endTime" expression="get-property('transport','endTime')"/>
<property name="uri.var.resultType"
expression="get-property('transport','resultType')"/>
<property name="uri.var.sampled" expression="get-property('transport','sampled')"/>
</log>
<property name="uri.var.kkscode"
expression="get-property('transport','kksCodes')"/>
<property name="uri.var.startTime"
expression="get-property('transport','startTime')"/>
<property name="uri.var.endTime" expression="get-property('transport','endTime')"/>
<property name="uri.var.resultType"
expression="get-property('transport','resultType')"/>
<property name="uri.var.sampled" expression="get-property('transport','sampled')"/>
<call>
<endpoint key="getKksCodeUrl"/>
</call>
<enrich>
<source type="body" clone="true"/>
<target type="property" property="_payload"/>
</enrich>
<log>
<property name="返回的kks地址:" expression="get-property('_payload')"/>
</log>
<iterate continueParent="true" expression="//jsonElement" sequential="true">
<target>
<sequence>
<property name="uri.var.restful" expression="//jsonElement"/>
<log>
<property name="请求的实时值地址" expression="//jsonElement"/>
</log>
<send>
<endpoint>
<http method="post"
uri-template="{uri.var.restful}&method=getRTDataHistoryZip&startTime={uri.var.startTime}&endTime={uri.var.endTime}&resultType={uri.var.resultType}&sampled={uri.var.sampled}"/>
</endpoint>
</send>
</sequence>
</target>
</iterate>
</inSequence>
<outSequence>
<aggregate>
<completeCondition>
<messageCount min="2" max="-1"/>
</completeCondition>
<onComplete expression="//jsonObject">
<log level="full" separator=",">
<property name="gethistoryZip代理日志" value="请求历史数据完成!"/>
</log>
<log level="full"/>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<jsonObject xmlns="">
<BasicResponse>
<succeeded>1</succeeded>
</BasicResponse>
$1
</jsonObject>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="//jsonObject/RTDataSets"/>
</args>
</payloadFactory>
<send/>
</onComplete>
</aggregate>
</outSequence>
</target>
<description/>
</proxy>
调用代理服务,背景错误,错误信息:
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,128]
Message: 在文档的元素内容中找到无效的 XML 字符 (Unicode: 0x1f)。
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:598)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
at org.apache.axiom.util.stax.dialect.SJSXPStreamReaderWrapper.next(SJSXPStreamReaderWrapper.java:138)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 40 more
[2016-04-06 11:13:46,666] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:c28c0542-4879-4364-89be-50f4100965e1, Direction: response, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Content-Type:application/json;charset=UTF-8, Unexpected error sending message back, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><jsonObject><BasicResponse><succeeded>1</succeeded></BasicResponse><RTDataSets><tag>0101A0ABB01DA073H</tag><kksCode>EB001HP1MKA01MK002BA01J1CB001BB03</kksCode><type>1</type><RTDataValues><Value>
计划的结果应该是:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<jsonObject>
<BasicResponse>
<succeeded>1</succeeded>
</BasicResponse>
<RTDataSets>
<tag>0101A0ABB05DA001H</tag>
<kksCode>EB001HP1MKA01MK002BK01J1CB001AA01</kksCode>
<type>1</type>
<RTDataValues>
<Value>
\u001F\b\u0000\u0000\u0000\u0000\u0000\u0000\u0000mkºô(¯C'ô~\u0012®fþ\u0013;Tï²´è¢ÿµÞìT\b`l·õ\u0015uÌõìÿþ÷Ï?½¾ão¢ï\u0007}þy£Áò\u0005[4õ\u000Fl5^í{ÓYú2Úÿ.\u001B08ò÷'n:\u0013ì£\u001A¿¿\u001F3\u0000®_ðsÝ¿`)£\u0018ü¶©¼nS
003ÛìÙ\u0010Ò¡Ú\n\u001FݨWD¯½ê\u0005+È>$F\\\u001BæS
C\u001AÅ^GBY\u0003¼ËN\u001CWÆ\r´é\u0010ºË¶Wì\u0018ç@P{\u0002\u000BM¸G5\n_\u000FÍ\u001D5và÷ÛHÁøy\u0010¦s#6O0Ó
Ý\u001A=4©QÙCUUöÐl\u0003\u0011J¤âD\u0004¢TÇ\u001EÇxqÍ&ö0¡MN:qV¾ÙEϺn}àT\u0005ÔÈ\u0003¦¬q«D\u0011(HX#~y¹L4;¸L4O0Ó;Ð\u0017ì¡É\u001D«=4÷R¬Û\u0016*Ä(Èsbݶ¼±nS+)\u0005=4yjÕ&,ÝfÅZjÛ+\u001C§·æZwqÚn¥>A³y\u0013Ôv\u0017¢ÅJ}ÔÞ&\u0018jËò\u0004NVÁF\u0013\u0002ÍR¡\u0005Ôöå³\u001FØÛF\u0013Bá\u0012hÞ±ÉD'\u0007øÄflÕ¨²\u0005(h±&k÷m£y¢qû1%¼ÙFó\u0000ÕYA´\\QõYµ}4y¢a©b\u0013\f^6'SË\u000EåÓ.!Ktâ@Nì5\u000B`r?,Ü+é\u0004·ÜËF\u0015AËU\u0016ØÛÛC©_yh2Å\u000E\u0013Mä\"a¢y
9\u0006¡:ÙD\u0013¹¥âÄ°\u0019,·aB\u000B¿\u0015Q\fFñÕn±}©Ò+s
°ËvÖdå
</Value>
<Time>1459838790000</Time>
</RTDataValues>
</RTDataSets>
</jsonObject>
</soapenv:Body>
</soapenv:Envelope>
我认为错误的原因是ESB payloadFactory后台解析错误,因为结果包含特殊字符。但我不知道如何解决。请给我一些想法..谢谢。