我正在简单代理服务中对传入的Soap / http请求执行XSLT转换。我收到以下错误。
注意: 我正在使用WSO2 ESB 4.8.1。
错误:
Unable to perform XSLT transformation using : Value {name ='null', keyValue ='gov:/xslt/Interface.xslt'} against source XPath : s11:Body/child::*[position()=1] | s12:Body/child::*[position()=1] reason : Unable to create an OMElement using XSLT result {org.apache.synapse.mediators.transform.XSLTMediator}
org.apache.synapse.SynapseException: Unable to create an OMElement using XSLT result
at org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:302)
at org.apache.synapse.mediators.transform.XSLTMediator.mediate(XSLTMediator.java:191)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:411)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:183)
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:744)
Caused by: org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[4,16]
Message: Content is not allowed in prolog.
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.synapse.util.jaxp.StreamResultBuilder.getNode(StreamResultBuilder.java:87)
at org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:300)
... 12 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[4,16]
Message: Content is not allowed in prolog.
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)
... 17 more
XSLT文件:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:con="http://com.example/cdm/contract/v1" xmlns:lic="http://com.example/cdm/license/v1" xmlns:org="http://com.example/cdm/organization/v1" xmlns:tns="http://com.example/cdm/order/v1" xmlns:tns1="http://com.example/cdm/customer/v1" xmlns:tns3="http://com.example/cdm/address/v1" xmlns:tns4="http://com.example/cdm/person/v1" xmlns:tns5="http://com.example/cdm/productoffer/v1" xmlns:tns6="http://com.example/cdm/product/v1" xmlns:tns7="http://com.example/cdm/productofferprice/v1" exclude-result-prefixes="tns tns1 tns4 tns3 tns5 tns6 tns7" version="1.0">
<xsl:template match="/tns:OrderRequest">
<tns:OrderRequest>
<tns:Order>
<tns:OrderHeader>
<tns:OrderNumber>
<xsl:value-of select="tns:OrderHeader/tns:OrderNumber" />
</tns:OrderNumber>
</tns:OrderHeader>
</tns:Order>
</tns:OrderRequest>
</xsl:template>
</xsl:stylesheet>
问题: 我不知道我的XSLT文件有什么问题。我在我的序言中看不到任何内容。
答案 0 :(得分:3)
错误表明转换结果在根元素之前有非空白文本。对此的唯一解释是,您的模板永远不会被触发,并且只应用默认模板(复制文本节点,但不复制元素)。这意味着转换输入的根元素不是tns:OrderRequest
。
答案 1 :(得分:1)
看起来您的配置和请求有效负载与此错误有关。请提供您的代理服务配置并输入xml有效负载,以便为您提供更多信息。
答案 2 :(得分:0)
如果你得到&#34;无法使用XSLT结果创建OMElement&#34;在错误中表示您的模板/命名空间在xslt中与请求消息不匹配。请检查开发人员评论here
答案 3 :(得分:0)
通常不会由XSLT来处理此错误的有效载荷。一旦收到此错误,所有传入的有效负载将无法处理是否已更正有效负载。
解决方案: 在“更改本地条目和代理服务文件中的键值”之后,重新启动wso2esb。
永久解决方案: 编写自定义XSLT介体以解决此问题