1

我正在使用 wso2 esb 4.8.1。我正在尝试在 smooks 调解器的帮助下进行 xml 到 xml 的转换,但是当来自 wso2 的应用程序部署控制台的 try it 命中请求时,我得到以下异常,

[2014-11-07 09:39:20,401] ERROR - SmooksMediator Failed to filter source.
org.milyn.SmooksException: Failed to filter source.
    at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:86)
    at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:61)
    at org.milyn.Smooks._filter(Smooks.java:516)
    at org.milyn.Smooks.filterSource(Smooks.java:475)
    at org.wso2.carbon.mediator.transform.SmooksMediator.mediate(SmooksMediator.java:123)
    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:724)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1236)
    at org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:70)
    at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:75)
    ... 15 more
[2014-11-07 09:39:20,417] ERROR - NativeWorkerPool Uncaught exception
org.wso2.carbon.mediator.service.MediatorException: Failed to filter source. Caused by Failed to filter source.
    at org.wso2.carbon.mediator.transform.SmooksMediator.handleException(SmooksMediator.java:242)
    at org.wso2.carbon.mediator.transform.SmooksMediator.mediate(SmooksMediator.java:137)
    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:724)

seqence xml如下,

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="smooksTransService" transports="http https" startOnLoad="true" trace="disable">
    <target>
        <inSequence>
            <log level="full" separator=","/>
            <smooks config-key="gov:/_system/config/transforms/smooksconfig.xml">
                <input type="text"/>
                <output type="xml"/>
            </smooks>
            <log level="full" separator=","/>
            <drop/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </target>
</proxy>

下面是smooks的配置文件,

<?xml version="1.0" encoding="UTF-8"?><smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd">
  <params>
    <param name="stream.filter.type">SAX</param>
    <param name="inputType">input.xml</param>
    <param name="default.serialization.on">true</param>
    <param name="input.xml" type="input.type.actived">File:/C:\Shailesh\xmls\model-input.xml</param>
  </params>
  <ftl:freemarker applyOnElement="#document">
    <ftl:template><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<h:salesorder xmlns:h="http://www.w3.org/TR/html4/">
    <h:details>
        <h:orderid>${.vars["order"]["@id"]}</h:orderid>        
        <h:customer>
            <h:id>${.vars["order"]["header/customer/@number"]}</h:id>            
            <h:name>${.vars["order"]["header/customer"]}</h:name>            
        </h:customer>        
    </h:details>    
    <#list .vars["order"]["order-items"] as order_items>
    <h:itemList>
        <#list .vars["order_items"]["order-item"] as order_item>
        <h:item>
            <h:id>${.vars["order_item"]["@id"]}</h:id>            
            <h:productId>${.vars["order_item"]["product"]}</h:productId>            
            <h:quantity>${.vars["order_item"]["quantity"]}</h:quantity>            
            <h:price>${.vars["order_item"]["price"]}</h:price>            
        </h:item>
        </#list>        
    </h:itemList>
    </#list>    
</h:salesorder>]]></ftl:template>
    <param name="modelSrc">File:/C:\Shailesh\xmls\model-output.xml</param>
    <param name="modelSrcType">XML</param>
    <param name="mess![enter image description here][2]ageType">XML</param>
    <param name="templateDataProvider">input</param>
  </ftl:freemarker>
  <resource-config selector="#document">
    <resource>org.milyn.delivery.DomModelCreator</resource>
  </resource-config>
</smooks-resource-list>

我对代理服务的请求如附图所示。

在此处输入图像描述

4

1 回答 1

1

我没有彻底浏览您的示例,但似乎错误是Smooks Mediator找不到注册表资源。

指定 smooks config-key 属性时似乎存在问题。当您使用注册表时,您需要知道有不同的注册表空间。

如果您通过“gov:”引用资源,则该资源将位于“/_system/governance”中。您需要使用“conf:”来引用“/_system/config”中的资源。

例如:如果你在“/_system/config/transforms/smooksconfig.xml”中有一个资源,你需要引用它如下:

“conf:transforms/smooksconfig.xml”

相关问题:如何在 WSO2 ESB 中访问注册表

我希望这有帮助。

于 2014-11-07T12:18:33.697 回答