<?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 / in文件夹中的信息的内容 内容如下:
ContactType,FirstName,MiddleName,LastName,Email,PhoneNumber,Company,Address1,Address2,Address3,Zip,Country,FaxsimileTelephoneNumber,PartnerFinanceID 1,ABC,A,CBD,test @ test.com,123456789,Test,200WS, 300 WSD,400tyu,125kji,World,4567894585,虚拟
请帮助您进行输入。请让我知道是否需要我的更多信息...........
答案 0 :(得分:0)
您可以通过为axis2.xml中的text / csv内容类型配置org.apache.axis2.format.PlainTextBuilder和org.apache.axis2.format.PlainTextFormatter来访问CSV的请求/响应有效负载中的内容。例如:
<messageBuilder contenttype="text/csv" class="org.apache.axis2.format.PlainTextBuilder"/>
<messageFormatter contenttype="text/csv" class="org.apache.axis2.format.PlainTextFormatter"/>