我的代理服務從Gmail IMAP服務器接收電子郵件。電子郵件也有csv
文件附件。 WSO2 ESB成功收到郵件,但在日誌中附件內容被打印爲base64編碼的字符串。以下是我的axis2.xml
connfigs。爲什麼WSO2 ESB在Base64中編碼電子郵件附件
<!-- ================================================= -->
<!-- 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">[email protected]</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任何方式保存該附件,因爲它是在目錄中?任何幫助將是非常有利的。
我認爲問題在於您還沒有爲multipart/mixed定義消息生成器。因此使用默認的消息生成器,不確定它是否是二進制。嘗試將相應的消息生成器添加到您的axis2.xml。以下鏈接也可能有助於更好地理解。 https://docs.wso2.com/display/ESB480/Working+with+Message+Builders+and+Formatters –
我也試過了。但仍然是在base64編碼。 –
您是否已將 text/plain 添加到您的代理?我認爲如果你分享你的整個代理配置,這將是最有效的。 –