wso2 esb smooks un / edifact 96a EDI to XML

时间:2014-11-24 07:36:06

标签: xml wso2 edi smooks edifact

我没有什么可以开始使用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应用程序中使用的这种配置与我完美配合。

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

1 个答案:

答案 0 :(得分:1)

同志, 经过大量的搜索和查询,我设法找到了一个部分但功能齐全的解决方案。首先,您必须正确识别您将阅读 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 ”改为“'”并使用正则表达式删除其中的所有内容:< / p>

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

通过这个,我们实现了在WSO2ESB中读取多个传入EDIFACT的痕迹。