'WSO2 EI get attachement filename in SOAP request

I need to get the filename of the attachment given in a SOAP request. The SOAP request looks like this :

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:type="http://some.type/types">
   <soap:Header/>
   <soap:Body>
      <type:RequestName>
         <type:Data>...</type:Data>
         <!--Optional:-->
         <type:myAttachement>cid:AAA</type:myAttachement>
      </type:RequestName>
   </soap:Body>
</soap:Envelope>

When MTOM is enabled in SOAP UI, I can see the following in the log Wire :


DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "         <type:myAttachement><inc:Include href="cid:AAA" xmlns:inc="http://www.w3.org/2004/08/xop/include"/></type:myAttachement>
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "      </type:RequestName>
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "   </soap:Body>[\n]"
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "</soap:Envelope>"
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "[\r][\n]"
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "------=_Part_2_1904033954.1651826827378[\r][\n]"
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "Content-Type: text/plain; charset=us-ascii; name=test.txt[\r][\n]"
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "Content-Transfer-Encoding: 7bit[\r][\n]"
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "Content-ID: <AAA>[\r][\n]"
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "Content-Disposition: attachment; name="test.txt"; filename="test.txt"[\r][\n]"
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "[\r][\n]"
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "AAABBBCCCDDD[\r][\n]"
DEBUG {wire} - HTTP-Listener I/O dispatcher-2 >> "------=_Part_2_1904033954.1651826827378--[\r][\n]"

I can see the filename, Content-Type.. When I Debug the request in the sequence, the file content is inline the SOAP Payload :

         <type:myAttachment>QUFBQkJCQ0NDRERE</type:myAttachment>
      </type:RequestName>
   </soap:Body></soap:Envelope>

How can I get in script mediator the attachment filename or at least the Content-Type of the attachment ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source