0

We have a requirement in which a Pdf needs to be sent to external system from salesforce. I have written a sample web service which can be invoked by external system and fetch pdf. Is this approach right?

// This is just a sample

global class Export_PDF
{
    webservice static Document exportPdf()
    {
        Document doc = [Select body from Document where Id='01521000000DJ6Z'];
        System.debug('-->  '+doc);
        return doc;
    }    
}

Thanks.

1
  • I dont see any problems with that, except that case when PDF is bigger, than SF heap size limit. As long as external system can authorize and call web service, probably it would make some sense to return only ID of the document, and then do get for that document by salesforce REST api
    – kurunve
    Feb 6 '17 at 10:41
0

I think it is better to send the binary PDF data by embeding directly in the SOAP envelope using base64 text encoding. The raw binary data is converted to an encoded String which is an XML element in the SOAP message. Upon receiving the SOAP message, the receiver decodes the encoded String in order to re-construct the original binary data.

For Base64 encoding refer this link http://www.salesforcegeneral.com/salesforce-articles/base-64-encoding-in-apex.html

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.