[SalesForce] Where can i find the header information in a webservice callout request

we are integrating Salesforce and SAP systems. For that we are making a callout to SAP with username and password in the header. When i checked the debug log the callout_request entry contains an xml request. But i did not find the header information which is the username and password in that request XML. Where can i find it? How could i ensure that i am sending the headers correctly? Experts please suggest. Thanks

           sap1.inputHttpHeaders_x = new Map<String, String>();

           //Setting a basic authentication header

           String username = 'SFDCUSER';
           String password = 'xxxxxxc1';  
           Blob headerValue = Blob.valueOf(username + ':' + password);
           String authorizationHeader = 'BASIC ' +EncodingUtil.base64Encode(headerValue);
           sap1.inputHttpHeaders_x.put('Authorization',authorizationHeader);

Best Answer

The DEBUG logging will have two CALLOUT_REQUEST entries.

The first will have the SOAP formatted POST body. I.e. the <env:Envelope ...>

<?xml version="1.0" encoding="utf-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Header />
  <env:Body>
    <login xmlns="urn:partner.soap.sforce.com">
      <username>user@example.com</username>
      <password>PasswordAndSecurityToken</password>
    </login>
  </env:Body>
</env:Envelope>

The second will have the same details, but JSON formatted. This will also end with the Request headers.

login_element: [
    apex_schema_type_info=(urn: partner.soap.sforce.com,
     true,
     false),
     field_order_type_info=(username,
     password),
     password=PasswordAndSecurityToken,
     password_type_info=(password,
     urn: partner.soap.sforce.com,
     string,
     1,
     1,
     false),
     username=user@example.com,
     username_type_info=(username,
     urn: partner.soap.sforce.com,
     string,
     1,
     1,
     false)
]: : Authorization=BASIC U0ZEQ1VTRVI6eHh4eHh4YzE= SOAPAction="" Accept=text/xml User-Agent=SFDC-Callout/36.0 SFDC_STACK_DEPTH=1 Content-Type=text/xml; charset=UTF-8 

The interesting part here is the trailing:

Authorization=BASIC U0ZEQ1VTRVI6eHh4eHh4YzE= SOAPAction="" Accept=text/xml User-Agent=SFDC-Callout/36.0 SFDC_STACK_DEPTH=1 Content-Type=text/xml; charset=UTF-8