Advanced Customization > Info*Engine User’s Guide > SOAP Services > Info*Engine Task Invocation with SOAP > BLOB Attachments on SOAP Requests
  
BLOB Attachments on SOAP Requests
Attachments can be used with SOAP requests to upload and download small amounts of binary data.
* 
Only relatively small amounts of binary data should be transferred using SOAP. For information on uploading and downloading larger BLOBs, see Uploading and Downloading BLOBs .
Two special data types are used when attaching data to a SOAP request: javax.activation.DataSource and java.io.InputStream. These special data types support a specially formatted SOAP comment optionally listing the binary content type. Specifying the content type allows for more complete generated WSDL, including what type of content data is expected or is returned. Any valid content type can be specified, for example:
image/.gif
image/.jpeg
application/octet-stream
If no content type is specified, then the default application/octet-stream is used.
javax.activation.DataSource
Indicates that the client is attaching binary data. This data type is used only in an @param SOAP comment.
Use the following format:
@param javax.activation.DataSource file {contentType:content_type}
where content_type is the content type of the binary data.
java.io.InputStream
Indicates that the task responds with binary data. Used only in an @return SOAP comment.
Use the following format:
@return java.io.InputStream {contentType:content_type}
where content_type is the content type of the binary data. When the response is an attachment, no substitution syntax is specified.
Info*Engine does not support returning both an attachment and data. When a task produces a BLOB for SOAP, the SOAP response contains an empty response element.
Example BLOB Upload
The following task adds a BLOB to a database row.
<%@page language="java" session="false"%>
<%@taglib uri="http://www.ptc.com/infoengine/taglib/core"
                                                     prefix="ie"%>

<!--com.infoengine.soap.rpc.def
upload a blob

@param string filename - the filename to store
@param javax.activation.DataSource file - the file to store
(should be gif or jpeg)
-->

<ie:unit>
  <ie:webject name="Do-Sql" type="ACT">
    <ie:param name="INSTANCE" data="soapJDBCAdapter"/>
    <ie:param name="SQL" data="DELETE FROM BLOBTABLE WHERE
                                   name='$(@FORM[]filename[0])'"/>
    <ie:param name="CLASS" data="BLOBTEST"/>
    <ie:param name="GROUP_OUT" data="deleteResult"/>
    <ie:param name="BLOB_COUNT" data="0"/>
  </ie:webject>
  <ie:failure/>
</ie:unit>

<ie:webject name="Do-Sql" type="ACT">
  <ie:param name="INSTANCE" data="soapJDBCAdapter"/>
  <ie:param name="SQL" data="INSERT INTO BLOBTABLE VALUES
('$(@FORM[]filename[0])', NULL)"/>
  <ie:param name="CLASS" data="BLOBTEST"/>
  <ie:param name="GROUP_OUT" data="insertResult"/>
  <ie:param name="BLOB_COUNT" data="0"/>
  </ie:webject>

<ie:webject name="Put-Blob-Stream" type="OBJ">
  <ie:param name="INSTANCE" data="soapJDBCAdapter"/>
  <ie:param name="CLASS" data="BLOBTABLE"/>
  <ie:param name="ATTRIBUTE" data="FILECONTENT"/>
  <ie:param name="WHERE" data="(NAME='$(@FORM[]filename[0])')"/>
  <ie:param name="GROUP_OUT" data="$(@FORM[]group_out[])"
                                                default="output"/>
</ie:webject>
Example BLOB Download
The following task retrieves a BLOB from a database row.
<%@page language="java" session="false"%>
<%@taglib uri="http://www.ptc.com/infoengine/taglib/core"
                                                     prefix="ie"%>

<!--com.infoengine.soap.rpc.def
download a blob

@param string filename - the file name of the blob/image to
download (value from ListBlobs call)
@return java.io.InputStream a stream that contains the blob
-->

<ie:webject name="Send-Blob-Stream" type="OBJ">
  <ie:param name="INSTANCE" data="soapJDBCAdapter"/>
  <ie:param name="CLASS" data="BLOBTABLE"/>
  <ie:param name="ATTRIBUTE" data="FILECONTENT"/>
  <ie:param name="MIMETYPE" data="'application/octet-stream'"/>
  <ie:param name="WHERE" data="(NAME='$(@FORM[]filename[0])')"/>
  <ie:param name="FILENAME" data="test.doc"/>
  <ie:param name="GROUP_OUT" data="$(@FORM[]group_out[])"
                                                default="output"/>
</ie:webject>