Я пытаюсь использовать Data Mapper для преобразования CSV в JSON. Ниже прокси-сервис, который я написал.
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="csvtojson" startOnLoad="true" transports="http https vfs"
xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<property expression="$body/*[1]" name="body" scope="default" type="OM"/>
<log level="full">
<property name="PropertyName" value="Message tobe fed to mapper"/>
</log>
<datamapper config="gov:datamapper/csvtojsonmapping.dmc"
inputSchema="gov:datamapper/csvtojsonmapping_inputSchema.json"
inputType="CSV"
outputSchema="gov:datamapper/csvtojsonmapping_outputSchema.json"
outputType="JSON"/>
<log level="full">
<property name="property_name" value="aftermapping"/>
</log>
<property name="ContentType" scope="axis2" type="STRING"
value="application/json"/>
<log description="" level="full">
<property name="property_name" value="msgpropertyset as json"/>
</log>
<send>
<endpoint>
<http method="post" uri-template="https://www.google.com/"/>
</endpoint>
</send>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<parameter name="transport.PollInterval">1</parameter>
<parameter name="transport.vfs.FileURI">file:///tmp/in</parameter>
<parameter name="transport.vfs.ContentType">text/csv</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter
name="transport.vfs.MoveAfterFailure">file:///tmp/failure</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.Build">false</parameter>
<parameter name="transport.vfs.FileNamePattern">.*\.csv</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///tmp/out</parameter>
</proxy>
Уже включены ниже двух в файл axis2.xml:
При выполнении сервиса я получаю сообщение об ошибке ниже:
[2018-08-30 18:38:44,535] [EI-Core] ERROR - VFSTransportListener Error
processing File URI : file:///tmp/in/test.csv
org.apache.axiom.om.OMException:
com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code
34) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at
org.apache.axiom.om.impl.builder.StAXOMBuilder.next
(StAXOMBuilder.java:296)
at
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope
(StAXSOAPModelBuilder.java:204)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>
(StAXSOAPModelBuilder.java:154)
at
org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAPModelBuilder
(AbstractOMMetaFactory.java:73)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPModelBuilder
(AbstractOMMetaFactory.java:79)
at
org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder
(OMXMLBuilderFacto ry.java:196)
at org.apache.axis2.builder.SOAPBuilder.processDocument
(SOAPBuilder.java:65)
at org.apache.synapse.transport.vfs.VFSTransportListener.processFile
(VFSTransportListener.java:822)
at
org.apache.synapse.transport.vfs.VFSTransportListener.scanFileOrDirectory
(VFSTransportListener.java:477)
at org.apache.synapse.transport.vfs.VFSTransportListener.poll
(VFSTransportListener.java:188)
at org.apache.synapse.transport.vfs.VFSTransportListener.poll
(VFSTransportListener.java:134)
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.runWorker
(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException:
Unexpected character '"' (code 34) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar
(StreamScanner.java:639)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog
(BasicStreamReader.java:2052)
at com.ctc.wstx.sr.BasicStreamReader.next
(BasicStreamReader.java:1134)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next
(XMLStreamReaderWrapper.java:225)
at
(DisallowDoctypeDeclStreamReaderWrapper.java:34)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext
(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next
(StAXOMBuilder.java:214)
... 15 more
Это содержимое сообщений, которые я помещаю в папку / tmp /
Содержание выглядит следующим образом:
ContactType, FirstName, MiddleName, LastName, Email, PhoneNumber, Company, Address1, Address2, Address3, Zip, Country, FacsimileTelephoneNumber, PartnerFinanceID 1, ABC, A, CBD, test @ test.com, 123456789, Test, 200WS, 300 WSD, 400тю, 125кджи, World, 4567894585, манекен
пожалуйста, помогите с вашими данными. Пожалуйста, дайте мне знать, если вам нужна дополнительная информация с моей стороны ...........