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
NowshadNowshad 

Kindly help me to pass the Tibco user name and password as part of webserice call in Soap Header

Dear All,

 

 We are facing an issue, while sending the security credentials to Tibco web service. We tried different ways, to send below details as part of SOAP header but we were not not able to succeed and this is a major show-stopper. Need to address this issue immediately to proceed further.

 

Soap Header:-  Below Soap header we need to send to Tibco as part of callout from SFDC

 

   <soapenv:Header>

     <wsse:Security soap:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-

           open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="soap">

            <wsse:UsernameToken>

               <wsse:Username>tibadmin</wsse:Username>

               <wsse:Password Type="wsse:PasswordText">tibadmin</wsse:Password>

            </wsse:UsernameToken>

         </wsse:Security>

   </soapenv:Header>

 

Apex code:-

 

         xmlnsExampleCom1354865212525.MDCPLookUpSearch stub = new xmlnsExampleCom1354865212525.MDCPLookUpSearch();   
         stub.endpoint_x='https://g5t1173g.atlanta.hp.com/hpit/sfdc/dev/mdcp/lookupsearch';
         stub.timeout_x=60000;
         stub.clientCertName_x='SFDC_Certificate';
         stub.inputHttpHeaders_x = new Map<String, String>();
         String myData = 'tibadmin:tibadmin';
        //Blob hash = Crypto.generateDigest('SHA1',Blob.valueOf(myData));
        //  String encodedusernameandpassword = EncodingUtil.base64Encode(hash);
        String encodedusernameandpassword = EncodingUtil.base64Encode(Blob.valueOf(myData));
        stub.inputHttpHeaders_x.put('Authorization','Basic ' + encodedusernameandpassword );// 

 

Error message rendered in SFDC as below: The meaning of the  error code 181001 is we are not able to sent the Authentication details as part of SOAP header.

 

Web service callout failed: WebService returned a SOAP Fault: WS Security Error : 181001 faultcode=SOAP-ENV:Server faultactor=

 

Please let me know, did we miss anything here. Just for your info, we installed the certificate and configured the end point in SPA proxy server and we were able test the same in SOAP UI. The issue is in SFDC, how do we pass these credentials as part of the soap header.

 

Thanks

Nowshad

 

NowshadNowshad

I fixed as below

 DateTime d = System.now();
         String createdStr = d.formatGmt('yyyy-MM-dd HH:mm:ss.SSSSSS');
         String nonceStr = String.valueOf(Crypto.getRandomInteger());                           
         Blob nonceBlob = Blob.valueOf(nonceStr);
         nonceStr=EncodingUtil.base64Encode(nonceBlob);
        SearchAccountMDCPLookUpStub.MDCPLookUpSearch stub = new SearchAccountMDCPLookUpStub.MDCPLookUpSearch();   
         stub.endpoint_x='https://g5t1173g.atlanta.hp.com/hpit/sfdc/itg/mdcp/lookupsearch';
         stub.timeout_x=600;
         stub.clientCertName_x='SFDC_Certificate';
         stub.inputHttpHeaders_x = new Map<String, String>();
         stub.inputHttpHeaders_x.put('Content-Type', 'application/soap+xml');
         stub.inputHttpHeaders_x.put('SOAPAction','/SFDCServices/MDCPLookUpSearch.serviceagent/MDCPLookUp/MDCPLookUpSearch');

         SearchAccountMDCPLookUpService.organizationAccountSearchResponse_element accountSearchOutputElementList = stub.MDCPLookUpSearch(mdcpQuery,0,30,'tibadmin','tibadmin',nonceStr,createdStr);        
 //Need to add below code in stub

NowshadNowshad

public class SearchAccountMDCPLookUpStub {    public class MDCPLookUpSearch {       public String endpoint_x = 'https://g5t1173g.atlanta.hp.com/hpit/sfdc/itg/mdcp/lookupsearch';           //SNA        public SearchMDCPLookUpStub.Security_element Security;        private String Security_hns = 'Security=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';        //End SNA        private String[] ns_map_type_info = new String[]{'urn:x-hp-it-cas:foundation', 'AccountLookupxHpItCasFoundation', 'http://xmlns.example.com/1354865212525', 'SearchAccountMDCPLookUpStub', 'http://www.tibco.com/schemas/MDCP2SFDC-LookUp/Schemas/accountSearchList.xsd', 'SearchAccountMDCPLookUpService'};        public SearchAccountMDCPLookUpService.organizationAccountSearchResponse_element MDCPLookUpSearch(String query,Integer offset,Integer limit_x,String userid,String password,String nonce,String dateVal) {              //SNA            Security = new SearchMDCPLookUpStub.Security_element(userid,password,nonce,dateVal);             //End SNA               }    }          public class Security_element{                           public Security_element(String username, String password,String nonce,String dateVal ) {                                  usernameToken = new UsernameToken_element(username,password,nonce,dateVal);                                  }        public UsernameToken_element usernameToken;        private String[] usernameToken_type_info = new String[]{'n1:UsernameToken','http://www.w3.org/2001/XMLSchema','element','1','1','false'};        private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd','true','false'};        private String[] field_order_type_info = new String[]{'usernameToken'};       }       public class UsernameToken_element {                           public UsernameToken_element(String username, String password,string nonce,string dateVal) {                     this.username = username;                     this.password = password;                     this.nonce= nonce;                     this.created= dateVal;                                  }                     public String username;        public String password;        public String nonce;        public String created;        private String[] username_type_info = new String[]{'n1:Username','http://www.w3.org/2001/XMLSchema','string','1','1','false'};        private String[] nonce_type_info = new String[]{'n1:Nonce','http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary','string','1','1','false'};        private String[] created_type_info = new String[]{'n1:Created','http://www.w3.org/2001/XMLSchema','string','1','1','false'};        private String[] password_type_info = new String[]{'n1:Password','http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText','string','1','1','false'};        private String[] apex_schema_type_info = new String[]{'http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd','true','false'};        private String[] field_order_type_info = new String[]{'username','password','nonce','created'};    }}