我的代理服务从Gmail IMAP服务器接收电子邮件。电子邮件也包含csv
文件附件。 WSO2 ESB成功收到了电子邮件,但在日志中,附件内容打印为 base64 编码的字符串。以下是我的axis2.xml
connfigs。
<!-- ================================================= -->
<!-- Message Formatters -->
<!-- ================================================= -->
<!-- Following content type to message formatter mapping can be used to implement support -->
<!-- for different message format serializations in Axis2. These message formats are -->
<!-- expected to be resolved based on the content type. -->
<messageFormatters>
<messageFormatter contentType="application/x-www-form-urlencoded"
class="org.apache.synapse.commons.formatters.XFormURLEncodedFormatter"/>
<messageFormatter contentType="multipart/form-data"
class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
<messageFormatter contentType="application/xml"
class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
<messageFormatter contentType="text/xml"
class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
<messageFormatter contentType="application/soap+xml"
class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
<messageFormatter contentType="text/plain"
class="org.apache.axis2.format.PlainTextFormatter"/>
<messageformatter contenttype="text/csv" class="org.apache.axis2.format.PlainTextFormatter"/>
<!--JSON Message Formatters-->
<messageFormatter contentType="application/json"
class="org.apache.synapse.commons.json.JsonStreamFormatter"/>
<!--messageFormatter contentType="application/x-www-form-urlencoded"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/-->
<!--messageFormatter contentType="multipart/form-data"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/-->
<messageFormatter contentType="application/xml"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
<!--messageFormatter contentType="text/html"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/-->
<!--messageFormatter contentType="application/soap+xml"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/-->
<messageFormatter contentType="text/xml"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
<!--messageFormatter contentType="x-application/hessian"
class="org.apache.synapse.format.hessian.HessianMessageFormatter"/-->
<!--messageFormatter contentType=""
class="org.apache.synapse.format.hessian.HessianMessageFormatter"/-->
<!--messageFormatter contentType="application/edi-hl7"
class="org.wso2.carbon.business.messaging.hl7.message.HL7MessageFormatter"/-->
</messageFormatters>
<!-- ================================================= -->
<!-- Message Builders -->
<!-- ================================================= -->
<!-- Following content type to builder mapping can be used to implement support for -->
<!-- different message formats in Axis2. These message formats are expected to be -->
<!-- resolved based on the content type. -->
<messageBuilders>
<messageBuilder contentType="application/xml"
class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
<messageBuilder contentType="application/x-www-form-urlencoded"
class="org.apache.synapse.commons.builders.XFormURLEncodedBuilder"/>
<messageBuilder contentType="multipart/form-data"
class="org.apache.axis2.builder.MultipartFormDataBuilder"/>
<messageBuilder contentType="text/plain"
class="org.apache.axis2.format.PlainTextBuilder"/>
<!--JSON Message Builders-->
<messagebuilder contenttype="text/csv" class="org.apache.axis2.format.PlainTextBuilder"/>
<messageBuilder contentType="application/json"
class="org.apache.synapse.commons.json.JsonStreamBuilder"/>
<messageBuilder contentType="application/xml"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
<!--messageBuilder contentType="application/x-www-form-urlencoded"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/-->
<!--messageBuilder contentType="multipart/form-data"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/-->
<messageBuilder contentType="multipart/related"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
<!--<messageBuilder contentType="multipart/related" class="org.apache.axis2.builder.MIMEBuilder"/>-->
<!--messageBuilder contentType="application/soap+xml"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/-->
<messageBuilder contentType="text/plain"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
<messageBuilder contentType="text/xml"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
<!--messageBuilder contentType="x-application/hessian"
class="org.apache.synapse.format.hessian.HessianMessageBuilder"/-->
<!--messageBuilder contentType=""
class="org.apache.synapse.format.hessian.HessianMessageBuilder"/-->
<!--messageBuilder contentType="application/edi-hl7"
class="org.wso2.carbon.business.messaging.hl7.message.HL7MessageBuilder"/-->
</messageBuilders>
日志:
INFO - LogMediator To: /services/MailService MessageID: urn:uuid:492da964-ee6c-4ae7-b444-269ba8a52641 Direction: request%%%%%%%%%%%%Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns:binary xmlns:ns="http://ws.apache.org/commons/ns/payload">LS05NGViMmMxNDMyYmFmNmU3N2EwNTRiNGJiMzc5DQpDb250ZW50LVR5cGU6IG11bHRpcGFydC9hbHRlcm5hdGl2ZTsgYm91bmRhcnk9OTRlYjJjMTQzMmJhZjZlNzc2MDU0YjRiYjM3Nw0KDQotLTk0ZWIyYzE0MzJiYWY2ZTc3NjA1NGI0YmIzNzcNCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOA0KDQoNCg0KLS05NGViMmMxNDMyYmFmNmU3NzYwNTRiNGJiMzc3DQpDb250ZW50LVR5cGU6IHRleHQvaHRtbDsgY2hhcnNldD1VVEYtOA0KDQo8ZGl2IGRpcj0ibHRyIj48L2Rpdj4NCg0KLS05NGViMmMxNDMyYmFmNmU3NzYwNTRiNGJiMzc3LS0NCi0tOTRlYjJjMTQzMmJhZjZlNzdhMDU0YjRiYjM3OQ0KQ29udGVudC1UeXBlOiB0ZXh0L2NzdjsgY2hhcnNldD1VUy1BU0NJSTsgbmFtZT0iY3N2LmNzdiINCkNvbnRlbnQtRGlzcG9zaXRpb246IGF0dGFjaG1lbnQ7IGZpbGVuYW1lPSJjc3YuY3N2Ig0KQ29udGVudC1UcmFuc2Zlci1FbmNvZGluZzogYmFzZTY0DQpYLUF0dGFjaG1lbnQtSWQ6IGZfajBra3Q0OWYwDQoNCmQyRnhZWE1zWVdkbERRcDNZWEZoY3l3eU13PT0NCi0tOTRlYjJjMTQzMmJhZjZlNzdhMDU0YjRiYjM3OS0tDQo=</ns:binary></soapenv:Body></soapenv:Envelope></soapenv:Body></soapenv:Envelope>
[2017-03-22 11:16:46,049] DEBUG - RelayUtils Content Type is multipart/mixed; boundary=94eb2c1432baf6e77a054b4bb379
代理代码:
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="MailTransportProtocolIMAP"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="mailto">
<target>
<inSequence>
<log level="full" separator="---=== Invalid Subject ===---"/>
</inSequence>
<outSequence/>
</target>
<parameter name="mail.imap.starttls.enable">false</parameter>
<parameter name="mail.imap.socketFactory.port">993</parameter>
<parameter name="transport.mail.Address">mapperxslt1@gmail.com</parameter>
<parameter name="mail.imap.fetchsize">100000</parameter>
<parameter name="mail.imap.user">mapperxslt1</parameter>
<parameter name="mail.imap.password">Password</parameter>
<parameter name="transport.mail.ActionAfterProcess">MOVE</parameter>
<parameter name="mail.imap.host">imap.gmail.com</parameter>
<parameter name="transport.mail.ContentType">multipart/mixed</parameter>
<parameter name="transport.mail.MoveAfterProcess">Processed</parameter>
<parameter name="mail.imap.port">993</parameter>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="transport.mail.Protocol">imap</parameter>
<parameter name="transport.mail.Folder">inbox</parameter>
<parameter name="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</parameter>
<parameter name="mail.imap.ssl.enable">false</parameter>
<parameter name="mail.imap.socketFactory.fallback">false</parameter>
<description/>
</proxy>
WSO2 ESB中是否有任何方法可以保存目录中的附件?任何帮助都会很有帮助。
答案 0 :(得分:0)
您可以通过注册&#34; org.apache.axis2.format.PlainTextBuilder&#34;来访问csv的请求/响应有效负载内的内容。和&#34; org.apache.axis2.format.PlainTextFormatter&#34;作为text / csv content-type的消息构建器和格式化程序。
请将以下格式化程序和构建器添加到axis2.xml。请检查建设者。
<messageformatter contenttype="text/csv" class="org.apache.axis2.format.PlainTextFormatter"/>
<messagebuilder contenttype="text/csv" class="org.apache.axis2.format.PlainTextBuilder"/>