Salesforce Certified Platform Developer II — Question 136
A developer has generated Apex code from a WSDL for an external web service. The web service requires Basic authentication.
What code should the developer use to authenticate?
Answer options
- A. Http.setHeader ('Authorization' , 'Basic QthZGprjpchVulHNchFtZQ')
- B. stub.inputHttpHeaders_x.put('Authorization' , 'Basic QthZGprjpchVulHNchFtZQ')
- C. Http.setAuthentication('Basic QthZGprjpchVulHNchFtZQ')
- D. stub.authentication.put ('Authorization','Basic QthZGprjpchVulHNchFtZQ')
Correct answer: B
Explanation
The correct answer is B because it uses the appropriate method to add the 'Authorization' header to the HTTP request for the generated stub. Option A is incorrect as it is meant for general HTTP requests, option C is not a valid method for setting authentication in this context, and option D is improperly structured for adding headers in this scenario.