簡體   English   中英

如何在dataweave中將SFTP字節有效負載轉換為Java

[英]How to convert SFTP byte payload to java in dataweave

我正在嘗試使用dataweave將SFTP字節有效負載轉換為java,以便可以使用現有流遍歷輸入記錄。 我該怎么做呢?

我已經在Dataweave中將其設置為java,並且預覽應該提供正確的輸出,但是當我運行它時,它是一個字節,我在轉換消息連接器之前轉換為例如String,但在轉換消息連接器之后仍保留為字符串。

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns:batch="http://www.mulesoft.org/schema/mule/batch" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
    <http:request-config name="HTTP_Request_Configuration" host="${host}" port="${userprocess.port}" doc:name="HTTP Request Configuration"></http:request-config>
    <sftp:connector name="SFTP" validateConnections="true" doc:name="SFTP" pollingFrequency="1000000"/>
    <flow name="userexperienceFlow" >
        <sftp:inbound-endpoint connector-ref="SFTP" host="localhost" port="2222" path="//input" user="${ftp.user}" password="${ftp.password}" responseTimeout="10000" doc:name="SFTP"/>
        <dw:transform-message doc:name="Transform Message">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload]]></dw:set-payload>
        </dw:transform-message>
        <logger level="INFO" doc:name="Logger"/>
        <sftp:outbound-endpoint exchange-pattern="one-way" host="localhost" port="2222" responseTimeout="10000" doc:name="SFTP" connector-ref="SFTP" password="${ftp.password}" path="//output" user="${ftp.user}" outputPattern="#[message.inboundProperties.originalFilename+'.processed']"/>  
    </flow>
</mule>

CSV文件

UserId,UserStatus
ON1234,active
ON1235,active

謝謝

嘗試將消息記錄為#[message.payloadAs(java.lang.String)]而不是#[payload]

還要在此<dw:set-payload>之前添加<dw:input-payload mimeType="application/csv" />

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM