Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending images from gallery to Web Service using SOAP

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;

  1. Send the text data.
  2. Check if the file already exists on the server.
  3. Send the file.
  4. Link the file with a record on the server using a u_id sent back from the server.

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.

like image 540
user963551 Avatar asked Sep 25 '11 11:09

user963551


1 Answers

There are three ways of sending attachments with SOAP.

  • base64Binary
  • SwA - SOAP with Attachments
  • MTOM

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.

like image 143
Prabath Siriwardena Avatar answered Sep 20 '22 07:09

Prabath Siriwardena