I have trawled the net and can't find any documentation on sending images (or any attachments) to a Web Service using SOAP.
I have been sending text data fine but I now need to send images from the gallery along with the text data, which poses another problem - making two or more async tasks at once. I will need to make 4 calls in total IF the record to send has an image affiliated with it;
I was advised to use a Base64 method to convert the file to a String then send it but I have a feeling theres a cleaner way of doing it using SOAP (no pun intended).
Any feedback greatly appreciated.
* Please note that I was using a httpClient but had to change to using SOAP also I'm relatively new to Android so forgive me if I've said anything stupid here.
There are three ways of sending attachments with SOAP.
base64Binary sends the attachments as base64 inline in the SOAP message. i.e. The Attachment in embedded in the SOAP Message. Bloats the message by 33%.
SWA sends the Attachment outside the SOAP message (The SOAP message contains a reference to the attachment). But the SOAP infoset does not contain the attachment.
MTOM Provides the best of both world. The Attachment is sent outside the SOAP message with a reference to it but the attachment appears as if it is embedded in the SOAP message (The SOAP infoset contains the attachment)
Due to the fact that attachments sent using MTOM appear as it the attachment is part of the SOAP message it allows you to use other WS-* QOS (Quality of Service) attributes. For e.g MTOM messages can be signed and encrypted using WS-Security. Thus this provides a mechanism to send Secured Attachments without the need for additional specs.
This example shows how to use MTOM with Apache AXIS2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With