10

We are working on exposing some internal services to Salesforce. One of the things we would like to do is retrieve PDFs from a SOAP web service. I'm trying to figure out what format Salesforce can handle, so I can ask the web services team to build something I can actually use. Do I need the internal service to return the PDF as a base64 encoded string? Also does the platform handle compression? If the response is gzipped, will the platform automatically unzip it?

1 Answer 1

12

Your server should perform all actions based on the Accept-Type and Accept-Encoding headers. Compression and TLS/SSL encryption is supported. Compression must be enabled with HttpRequest.setCompression(true), salesforce.com will configure the appropriate headers for you.

The Content-Type should be application/octet-stream or application/pdf (doesn't matter, just make sure its a binary type), Transfer-Encoding may be any HTTP/1.1 legal value (assuming Accept-Encoding allows it), and Content-Length etc should be set, just as you would for any browser.

In other words, you shouldn't make any special exceptions for salesforce.com in regards to encoding, compression, or encryption. Normal binary content is natively supported without Base64 encoding.

Compression is allowed as long as it was originally requested, and the returned Blob will already be decompressed and decrypted in memory by the time Apex Code has a chance to examine/save it to an attachment/document/etc. The maximum pre-compressed size of the file will be 3MB; this is the only special limitation you need to be aware of.

You should return a special status value, such as 401 (Bad Request) to indicate files that would violate the limit. This lets you gracefully detect files that are too large, and you can inform the user. Otherwise, you'll have a hard stop and won't be able to gracefully display an error message.

2
  • 1
    Great points on the 3MB pre-compressed size limitation and the un-catchable error if exceeded.
    – Adam
    Aug 27, 2013 at 16:09
  • Thanks for the info! Callouts to grab attachments are a brave new world for me. Aug 27, 2013 at 16:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .