0

我正在尝试使用 Smooks 调解器转换消息队列中的消息。我按照本教程进行操作: http ://wso2.com/library/tutorials/2011/06/perform-data-mapping-smooks-editor-wso2-carbon-studio/ 但我遇到了这样的错误:

    [2015-07-01 06:09:23,986] ERROR - SmooksMediator Failed to filter source.
org.milyn.SmooksException: Failed to filter source.
        at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:97)
        at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:64)
        at org.milyn.Smooks._filter(Smooks.java:526)
        at org.milyn.Smooks.filterSource(Smooks.java:482)
        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$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.IllegalArgumentException: prefix cannot be "null" when creating a QName
        at javax.xml.namespace.QName.<init>(QName.java:253)
        at com.sun.xml.internal.stream.events.XMLEventAllocatorImpl.getQName(XMLEventAllocatorImpl.java:256)
        at com.sun.xml.internal.stream.events.XMLEventAllocatorImpl.getXMLEvent(XMLEventAllocatorImpl.java:78)
        at com.sun.xml.internal.stream.events.XMLEventAllocatorImpl.allocate(XMLEventAllocatorImpl.java:55)
        at com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(XMLEventReaderImpl.java:86)
        at com.sun.xml.internal.stream.XMLEventReaderImpl.next(XMLEventReaderImpl.java:250)
        at org.wso2.carbon.mediator.transform.stream.IOElementPipe.populateEvents(IOElementPipe.java:90)
        at org.wso2.carbon.mediator.transform.stream.IOElementPipe.getData(IOElementPipe.java:68)
        at org.wso2.carbon.mediator.transform.stream.ElementInputStream.read(ElementInputStream.java:61)
        at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
        at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
        at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
        at java.io.InputStreamReader.read(InputStreamReader.java:167)
        at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
        at org.apache.xerces.impl.XMLEntityScanner.skipString(Unknown Source)
        at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:76)
        at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:86)
        ... 15 more
[2015-07-01 06:09:23,986] ERROR - NativeWorkerPool Uncaught exceptionorg.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$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)

我的 inSequence 定义如下:

<inSequence>
         <log level="custom" separator=" == ">
            <property name="StartingLogging" value="------ STARTING PS ------"/>
         </log>
         <property name="message" expression="/" scope="default" type="STRING"/>
         <log level="custom">
            <property name="Message" expression="$ctx:message"/>
         </log>
         <payloadFactory media-type="xml">
            <format>
               <GeoRequest xmlns="">
                  <lat>$1</lat>
                  <long>$2</long>
               </GeoRequest>
            </format>
            <args>
               <arg xmlns:p="http://www.example.org/NewWSDLFile/"
                    evaluator="xml"
                    expression="$body/p:GeoRequest/lat/text()"/>
               <arg xmlns:p="http://www.example.org/NewWSDLFile/"
                    evaluator="xml"
                    expression="$body/p:GeoRequest/long/text()"/>
            </args>
         </payloadFactory>
         <log level="full"/>
         <smooks config-key="conf:smooks/DemoRequestTransform.xml">
            <input type="xml"/>
            <output type="xml" expression="$body/GeoRequest" action="replace"/>
         </smooks>
         <log level="full" separator=" *** "/>
         <send>
            <endpoint key="DemoGeoService"/>
         </send>
      </inSequence>

这是我的 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="input.xml" type="input.type.actived">file://E:\WSO2\workspace\DemoRegistryResources\RequestInputModel.xml</param>
  </params>
  <ftl:freemarker applyOnElement="#document">
    <ftl:template><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<geo:getZipCode xmlns:geo="http://geo.wso2">
    <geo:latitude>${.vars["Geolocation"]["lat"]}</geo:latitude>    
    <geo:longitude>${.vars["Geolocation"]["long"]}</geo:longitude>    
</geo:getZipCode>]]></ftl:template>
    <param name="modelSrc">file://E:\WSO2\workspace\DemoRegistryResources\RequetsOutputModel.xml</param>
    <param name="modelSrcType">XML</param>
    <param name="messageType">XML</param>
    <param name="templateDataProvider">input</param>
  </ftl:freemarker>
  <resource-config selector="#document">
    <resource>org.milyn.delivery.DomModelCreator</resource>
  </resource-config>
</smooks-resource-list>

Smooks 的配置有问题吗?

我对配置文件的标签“param”中的参数感到困惑。是否有必要将其上传到注册表?

你能给我一些建议来解决这个问题,或者给我一些用 Smooks 转换消息以进行 xml-to-xml-transformation 的方法吗?

谢谢,

4

0 回答 0