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
Ken Koellner @ EngagewareKen Koellner @ Engageware 

Named Credential Merge References in Headers Using SOAP Bindings

I'd like to use a merge field from a named credential -- $Credential.Username}.

I'm using a SOAP binding to the setHeader() method doesn't apply.

I'm wondering if the following will work.

myBindingVariable.inputHttpHeaders_x.put('X-USERNAME','{!$Credential.Username}');

Will that get merge in the request?  I put the check box on for allow merge references in header in the named cred.  I looked at the debug log and it shows "{!$Credential.Username}" but that may be because the debug log doesn't expand the merge reference.  I don't have access to the server right now to see if the header arrived.
VinayVinay (Salesforce Developers) 
Hi Ken,

Check below similar reference that can help you.

https://salesforce.stackexchange.com/questions/200951/namedcredential-soap-request-authentication-headers

Please mark as Best Answer if above information was helpful.

Thanks,