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
Vin25Vin25 

SOAP Header

Hi,

Has anyone worked on this before. I am working on integration between Salesforce -CornerStone using CornerStone SOAP API. I have generated apex classes from WSDL. Since, the soap header with username/password information is not generated by wsdl2apex, I have updated the apex classes to include username and password. However, I was able to get the below xml format by updating the apex class.
 
<env:Header> 
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
<UsernameToken> <Username>domainName/username</Username> 
<Password > <value>PSWDXX</value> </Password> 
</UsernameToken> 
</Security> 
</env:Header>

However, the API expects the below XML Request:
 
<o:UsernameToken u:Id="uuid-dd7a656b-27ae-4139-93fe-840d1681bb0e-1">
<o:Username>[CORPNAME]\[WEBSERVICEACCOUNT]</o:Username>
<o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-
200401-wss-username-token-profile-
1.0#PasswordText">password</o:Password>
</o:UsernameToken>

How do I code the apex class inorder to include the password value without the additional <value> PWSDXX </value> tag.

Greatly appreciate any inputs.

APEX CLASS CODE SNIPPET:
 
//soap headers need to be generated and inserted for authentication against WSSE web-services
    public class Security {
    public UsernameToken usernameToken;
    public Security(UsernameToken u){
    	this.usernameToken = u;
    }
    private String[] usernameToken_type_info = new String[]{'UsernameToken','http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','UsernameToken','0','1','true'};
    private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
    private String[] field_order_type_info = new String[]{'usernameToken'};
    }
    
    public class UsernameToken {
    public String username;
    public Password password;
    
    public UsernameToken(String username, Password password){
    	this.username = username;
    	this.password = password;
    }
    
    private String[] username_type_info = new String[]{'Username','http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','string','0','1','true'};
    private String[] password_type_info = new String[]{'Password','http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','string','1','1','true'};
    private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
    private String[] field_order_type_info = new String[]{'username','password'};
    }
    
    public class Password {
    	
    public string Type;
    public string content;
    	
    public Password(String Type, String value){
    		this.Type = Type;
    		this.content = content;
    }
    
    private String[] Type_att_info = new String[]{'Type'};
    private String[] content_type_info = new String[]{'content','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
    private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd','true','false'};
    private String[] field_order_type_info = new String[]{'value'};	
    	
    }



Thanks!
branderTFAbranderTFA
Are you talking about getting a the namespace in there <namespace:tagName>?
Vin25Vin25
No, in the below XML Request I got, I want to pass the password value without the value tag. What updates I will need in my apex code to generate the xml without the value tag around the password.
 
<env:Header> 
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> 
<UsernameToken> <Username>domainName/username</Username> 
<Password > 
           <value>PSWDXX</value> 
</Password> 
</UsernameToken> 
</Security> 
</env:Header>