function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CaffeineCaffeine 

HTTP Callout: Specifying Compression?

I got a question from a customer today and just wanted to verify the answer with the community.

 

If I send an HTTP Callout to a web service that a customer has exposed, how do I make sure that it is compressed?  If I simply add an  HTTP header like: Content-Encoding: gzip  will that do it?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Rajesh ShahRajesh Shah
If you need to compress the data you send, use setcompressed, as the following sample illustrates:
 

Http Request req = new HttpRequest();req.setEndPoint('my_endpoint');req.setCompressed(true);req.setBody('some post body');

  If a response comes back in compressed format, getBody automatically recognizes the format, uncompresses it, and returns the uncompressed value.

for the setCompressed method:If true, data in the body is delivered to the endpoint in gzip compressed format. If false, no compression format is used.

All Answers

Rajesh ShahRajesh Shah
If you need to compress the data you send, use setcompressed, as the following sample illustrates:
 

Http Request req = new HttpRequest();req.setEndPoint('my_endpoint');req.setCompressed(true);req.setBody('some post body');

  If a response comes back in compressed format, getBody automatically recognizes the format, uncompresses it, and returns the uncompressed value.

for the setCompressed method:If true, data in the body is delivered to the endpoint in gzip compressed format. If false, no compression format is used.
This was selected as the best answer
CaffeineCaffeine
Thanks, Rajesh.  Much appreciated.
RKG_NITKRKG_NITK

Hi,

I am using the Web Services Connection framework (wsc-23.jar) for generating the binding jars from the Enterprise WSDL (version 28).

 

The service end point is at ( https://ap1-api.salesforce.com/services/Soap/c/28.0).

 

I used the HTTP Analyzer tool to verify that the payload for HTTP Request / Response, by default does not make use of data encryption logic. It is only using Gzip compression algorithm which is resulting in the payload as special characters. If I turn the compression off using ConnectorConfig.compression(“false”) in my code, the request and response body are transmitted as clear text.

 

Questions:

1.)    Is there an in built mechanism to support secure communication between my JAVA client and the SFDC web service, using digital certificates for data encryption? How does it work?

2.)    If not, is it recommended that I extract the SOAPConnection.java class from the jar & modify it to use encryption?

3.)    What will be the new service end point for secure communication?

 

Thanks,

Rahul