1

我几乎没有从 WSO2 ESB 开始,需要创建一个方案,允许我从通过 VFS(已启用)获得的 .edi 文件(96a)将其转换为 XML ......为此,我正在使用 Smooks 和UN / EDIFACT 执行解析。执行时会出现以下错误 WSO2:

[2014-01-16 08:16:44,684] ERROR - VFSTransportListener Error processing File URI : file:///home/pwcenter/Proxy_UnEdifact/in/wm_msg_download_xml_tipo_7.edi
org.milyn.cdr.SmooksConfigurationException: Error invoking @Initialize method 'initialize' on class 'org.milyn.smooks.edi.ModelLoader'.
        at org.milyn.cdr.annotation.Configurator.invoke(Configurator.java:457)
        at org.milyn.cdr.annotation.Configurator.initialise(Configurator.java:439)
        at org.milyn.cdr.annotation.Configurator.configure(Configurator.java:91)
        at org.milyn.cdr.annotation.Configurator.configure(Configurator.java:66)
        at org.milyn.delivery.JavaContentHandlerFactory.create(JavaContentHandlerFactory.java:63)
        at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.addCDU(ContentDeliveryConfigBuilder.java:623)
        at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyCDUStrategy(ContentDeliveryConfigBuilder.java:548)
        at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyStrategy(ContentDeliveryConfigBuilder.java:536)
        at org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.iterate(ContentDeliveryConfigBuilder.java:711)
        at org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.access$300(ContentDeliveryConfigBuilder.java:690)
        at org.milyn.delivery.ContentDeliveryConfigBuilder.extractContentHandlers(ContentDeliveryConfigBuilder.java:484)
        at org.milyn.delivery.ContentDeliveryConfigBuilder.load(ContentDeliveryConfigBuilder.java:349)
        at org.milyn.delivery.ContentDeliveryConfigBuilder.getConfig(ContentDeliveryConfigBuilder.java:146)
        at org.milyn.container.standalone.StandaloneExecutionContext.<init>(StandaloneExecutionContext.java:91)
        at org.milyn.container.standalone.StandaloneExecutionContext.<init>(StandaloneExecutionContext.java:65)
        at org.milyn.Smooks.createExecutionContext(Smooks.java:411)
        at org.milyn.Smooks.createExecutionContext(Smooks.java:374)
        at org.wso2.carbon.mediator.transform.SmooksMediator.mediate(SmooksMediator.java:103)
        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.axis2.transport.base.AbstractTransportListener.handleIncomingMessage(AbstractTransportListener.java:328)
        at org.apache.synapse.transport.vfs.VFSTransportListener.processFile(VFSTransportListener.java:597)
        at org.apache.synapse.transport.vfs.VFSTransportListener.scanFileOrDirectory(VFSTransportListener.java:328)
        at org.apache.synapse.transport.vfs.VFSTransportListener.poll(VFSTransportListener.java:158)
        at org.apache.synapse.transport.vfs.VFSTransportListener.poll(VFSTransportListener.java:107)
        at org.apache.axis2.transport.base.AbstractPollingTransportListener$1$1.run(AbstractPollingTransportListener.java:67)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: org.milyn.edisax.EDIConfigurationException: Failed to locate jar file for EDI Mapping Model URN 'org.milyn.edi.unedifact:d96a-mapping:*'.  Jar must be available on classpath.
        at org.milyn.edisax.util.EDIUtils.getMappingModelConfigStream(EDIUtils.java:300)
        at org.milyn.edisax.util.EDIUtils.getMappingModelList(EDIUtils.java:207)
        at org.milyn.edisax.util.EDIUtils.loadMappingModels(EDIUtils.java:118)
        at org.milyn.smooks.edi.ModelLoader.initialize(ModelLoader.java:52)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.milyn.cdr.annotation.Configurator.invoke(Configurator.java:453)
        ... 32 more

Smooks的配置是:

<?xml version="1.0"?>    
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
                       xmlns:unedifact="http://www.milyn.org/xsd/smooks/unedifact-1.4.xsd">
    <unedifact:reader mappingModel="urn:org.milyn.edi.unedifact:d96a-mapping:*" />
</smooks-resource-list>

我在 Java 应用程序中使用过同样的配置,而且我工作得很好。

此外,除了创建 CLASSPATH 甚至 build-classpath-directory 命令之外,我还尝试在 WSO2 中的 dropins 和 lib 目录中手动添加依赖项,但没有成功。

4

1 回答 1

2

同志们,经过多次搜索和询问,我设法找到了一个部分但功能齐全的解决方案。首先,您必须正确识别将读取EDIFACT映射的路径,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<localEntry xmlns="http://ws.apache.org/ns/synapse" key="smooks">
  <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:unedifact="http://www.milyn.org/xsd/smooks/unedifact-1.4.xsd">
    <unedifact:reader mappingModel="//opt//wso2//wso2esb-4.8.1//repository//components//lib//org.milyn.edi.unedifact.d96a-mapping_1.4.jar"/>
  </smooks-resource-list>
</localEntry>

有了这个,您已经可以读取EDIFACT文件,但有些包含任何不一致,因为只读取一个跟踪,但不读取多个跟踪,要修复您必须删除第一行:

UNB+UNOA:2+925485K200:8+7808800024232:1+150526:0108+168'
...

一种快速简便的方法是创建一个自定义调解器,它将“ UNB ”转换为“ ' ”并使用正则表达式删除其中的所有内容:

UNB[\\d|\\D|\\+|\\:]*'

有了这个,我们实现了在 WSO2ESB 中读取传入 EDIFACT 的多个跟踪。

于 2015-07-31T15:15:30.313 回答