WSO2 DOCTYPE不允许调用REST Api

时间:2015-05-21 12:07:31

标签: proxy wso2 wso2esb doctype

我正在使用此代理:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="PubMedDataProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <call>
            <endpoint>
               <http method="get"
                 uri-template="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?dbfrom=omim&amp;Mdb=pubmed&amp;id=230900"/>
            </endpoint>
         </call>
         <log level="custom">
            <property name="MyLOg" expression="//eLinkResult/DbFrom/text()"/>
         </log>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>

我得到了这个例外:

TID: [0] [ESB] [2015-05-21 13:45:34,838] ERROR {org.apache.synapse.transport.passthru.util.RelayUtils} -  Error while building Passthrough stream {org.apache.synapse.transport.passthru.util.RelayUtils}
org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,142]
Message: DOCTYPE is not allowed
    at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
    at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
    at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
    at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
    at org.apache.axis2.builder.ApplicationXMLBuilder.processDocument(ApplicationXMLBuilder.java:81)
    at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:118)
    at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:107)
    at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:82)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:68)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:239)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:556)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:198)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:488)
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:225)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,142]
Message: DOCTYPE is not allowed
...

在普通的REST客户端中调用服务,我得到了XML结果,没有任何问题。

当代理尝试解析生成的xml时出现问题。实际上,使用代理中的属性删除Log中介会正确返回结果。 我错过了什么?

2 个答案:

答案 0 :(得分:1)

将以下内容添加到您的代理:

<parameter name="ApplicationXMLBuilder.allowDTD">true</parameter>

答案 1 :(得分:0)

将以下参数添加到 <axisconfig name="AxisJava2.0"> 下的axis2.xml 文件中也有效。

<parameter name="ApplicationXMLBuilder.allowDTD">true</parameter>