WSO2 EI 6.5.0从收到的MTOM消息中提取文件名和内容类型

问题描述

使用WSO2 EI 6.5.0从MTOM消息中提取文件名和内容类型的正确方法是什么? 例如,Web服务具有附件列表:

<soapenv:Body>
    <ns1:attachmentList>
        <ns1:attachment>
            <ns1:attachmentContent>cid:test1</ns1:attachmentContent>
        </ns1:attachment>
    </ns1:attachmentList>
    <ns1:otherAttachmentList>
        <ns1:attachment>
            <ns1:attachmentContent>cid:test2</ns1:attachmentContent>
        </ns1:attachment>
    </ns1:otherAttachmentList>
</soapenv:Body>

这是来自SoapUI的原始调用的样子,我想从“内容类型:应用程序/ pdf;名称= test1.pdf”中提取信息:

------=_Part_14_155126574.1598958085923
Content-Type: application/pdf; name=test1.pdf
Content-transfer-encoding: binary
Content-ID: <test1>
...

我需要使用提取的信息将消息转换为此:

<soapenv:Body>
    <ns1:attachmentList>
        <ns1:attachment>
            <ns1:attachmentFileName>test1.pdf</ns1:attachmentFileName>
            <ns1:attachmentFileName>application/pdf</ns1:attachmentFileName>
            <ns1:attachmentContent>base64_encoded_value</ns1:attachmentContent>
        </ns1:attachment>
    </ns1:attachmentList>
    <ns1:otherAttachmentList>
        <ns1:attachment>
            <ns1:attachmentFileName>test2.pdf</ns1:attachmentFileName>
            <ns1:attachmentFileName>application/pdf</ns1:attachmentFileName>
            <ns1:attachmentContent>base64_encoded_value</ns1:attachmentContent>
        </ns1:attachment>
    </ns1:otherAttachmentList>
</soapenv:Body>

认情况下,WSO2使用base64编码将“ cid:”值替换为相应的文件内容,但是我还需要获取文件名和内容类型。 我可以创建自定义中介程序,以从getAttachmentMap获取这些值,但是如何将其与相应的attachmentList或otherAttachmentList映射?我无法比较base64内容值,因为两个列表的文件可能相同... 其他选择是关闭“ cid:”自动替换为base64编码-可以吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)