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
Ramssf70Ramssf70 

how to do basic authentication while calling soap webservice from soap

Hi Folks,
I need to third party soapservice web alesforce.I am confusing where i need to give username and password of third  party system.please help me

//Generated by wsdl2apex

public class PED_SmartinfoWSDL {
    public class DatiClienteType {
        public String Nome;
        public String Cognome;
        public String CodiceFiscale;
        public String RagioneSociale;
        public String PartitaIva;
        public PED_SmartinfoWSDL.IndirizzoType Indirizzo;
        private String[] Nome_type_info = new String[]{'Nome','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Cognome_type_info = new String[]{'Cognome','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] CodiceFiscale_type_info = new String[]{'CodiceFiscale','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] RagioneSociale_type_info = new String[]{'RagioneSociale','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] PartitaIva_type_info = new String[]{'PartitaIva','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Indirizzo_type_info = new String[]{'Indirizzo','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Nome','Cognome','CodiceFiscale','RagioneSociale','PartitaIva','Indirizzo'};
    }
    public class ServizioSIRicercaResponse_element {
        public PED_SmartinfoWSDL.EsitoType Esito;
        public PED_SmartinfoWSDL.ArrayOfEsitoRicercaType EsitiRicerca;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] EsitiRicerca_type_info = new String[]{'EsitiRicerca','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito','EsitiRicerca'};
    }
    public class ServizioSIGeneraFileRequest_element {
        public String Pod;
        public String SIIdentifier;
        public String NIDIdentifier;
        public String IdUtente;
        public String NomeUtente;
        private String[] Pod_type_info = new String[]{'Pod','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] SIIdentifier_type_info = new String[]{'SIIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] NIDIdentifier_type_info = new String[]{'NIDIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] IdUtente_type_info = new String[]{'IdUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] NomeUtente_type_info = new String[]{'NomeUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Pod','SIIdentifier','NIDIdentifier','IdUtente','NomeUtente'};
    }
    public class ServizioSIAssociazioneResponse_element {
        public PED_SmartinfoWSDL.EsitoType Esito;
        public String ConfigurazioneSI;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] ConfigurazioneSI_type_info = new String[]{'ConfigurazioneSI','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito','ConfigurazioneSI'};
    }
    public class ServizioSIAssociazioneRequest_element {
        public String Pod;
        public String SIIdentifier;
        public String NIDIdentifier;
        public String TipoConfigurazione;
        public String PodPROD;
        public String EneltelPROD;
        public String IdUtente;
        public String NomeUtente;
        private String[] Pod_type_info = new String[]{'Pod','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] SIIdentifier_type_info = new String[]{'SIIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] NIDIdentifier_type_info = new String[]{'NIDIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] TipoConfigurazione_type_info = new String[]{'TipoConfigurazione','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] PodPROD_type_info = new String[]{'PodPROD','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] EneltelPROD_type_info = new String[]{'EneltelPROD','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] IdUtente_type_info = new String[]{'IdUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] NomeUtente_type_info = new String[]{'NomeUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Pod','SIIdentifier','NIDIdentifier','TipoConfigurazione','PodPROD','EneltelPROD','IdUtente','NomeUtente'};
    }
    public class ServizioSISostituzioneResponse_element {
        public PED_SmartinfoWSDL.EsitoType Esito;
        public String ConfigurazioneSI;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] ConfigurazioneSI_type_info = new String[]{'ConfigurazioneSI','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito','ConfigurazioneSI'};
    }
    public class ServizioSIRimozioneRequest_element {
        public String Pod;
        public String Eneltel;
        public String IdUtente;
        public String NomeUtente;
        private String[] Pod_type_info = new String[]{'Pod','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] Eneltel_type_info = new String[]{'Eneltel','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] IdUtente_type_info = new String[]{'IdUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] NomeUtente_type_info = new String[]{'NomeUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Pod','Eneltel','IdUtente','NomeUtente'};
    }
    public class ServizioSIGeneraFileResponse_element {
        public PED_SmartinfoWSDL.EsitoType Esito;
        public String ConfigurazioneSI;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] ConfigurazioneSI_type_info = new String[]{'ConfigurazioneSI','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito','ConfigurazioneSI'};
    }
    public class ServizioSIRimozioneResponse_element {
        public PED_SmartinfoWSDL.EsitoType Esito;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito'};
    }
    public class ServizioSIRicercaRequest_element {
        public PED_SmartinfoWSDL.DatiFornituraType DatiFornitura;
        public PED_SmartinfoWSDL.DatiAnagraficiType DatiAnagrafici;
        public PED_SmartinfoWSDL.DatiBaseType DatiBase;
        public String IdUtente;
        public String NomeUtente;
        private String[] DatiFornitura_type_info = new String[]{'DatiFornitura','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] DatiAnagrafici_type_info = new String[]{'DatiAnagrafici','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] DatiBase_type_info = new String[]{'DatiBase','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] IdUtente_type_info = new String[]{'IdUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] NomeUtente_type_info = new String[]{'NomeUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'DatiFornitura','DatiAnagrafici','DatiBase','IdUtente','NomeUtente'};
    }
    public class EsitoType {
        public Integer Esito;
        public String Descrizione;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] Descrizione_type_info = new String[]{'Descrizione','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito','Descrizione'};
    }
    public class IndirizzoType {
        public String Via;
        public String NumeroCivico;
        public String CAP;
        public String Localita;
        public String CodiceIstat;
        private String[] Via_type_info = new String[]{'Via','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] NumeroCivico_type_info = new String[]{'NumeroCivico','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] CAP_type_info = new String[]{'CAP','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Localita_type_info = new String[]{'Localita','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] CodiceIstat_type_info = new String[]{'CodiceIstat','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Via','NumeroCivico','CAP','Localita','CodiceIstat'};
    }
    public class DatiBaseType {
        public String Nome;
        public String Cognome;
        public String RagioneSociale;
        public PED_SmartinfoWSDL.IndirizzoType Indirizzo;
        private String[] Nome_type_info = new String[]{'Nome','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Cognome_type_info = new String[]{'Cognome','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] RagioneSociale_type_info = new String[]{'RagioneSociale','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Indirizzo_type_info = new String[]{'Indirizzo','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Nome','Cognome','RagioneSociale','Indirizzo'};
    }
    public class FornituraType {
        public String POD;
        public String Eneltel;
        public String Matricola;
        public PED_SmartinfoWSDL.DatiClienteType DatiCliente;
        public String PotenzaContrattuale;
        public String SIIdentifier;
        public String TipoFornitura;
        public String VersoInserzione;
        public String TipoConfigurazione;
        private String[] POD_type_info = new String[]{'POD','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Eneltel_type_info = new String[]{'Eneltel','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Matricola_type_info = new String[]{'Matricola','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] DatiCliente_type_info = new String[]{'DatiCliente','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] PotenzaContrattuale_type_info = new String[]{'PotenzaContrattuale','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] SIIdentifier_type_info = new String[]{'SIIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] TipoFornitura_type_info = new String[]{'TipoFornitura','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] VersoInserzione_type_info = new String[]{'VersoInserzione','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] TipoConfigurazione_type_info = new String[]{'TipoConfigurazione','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'POD','Eneltel','Matricola','DatiCliente','PotenzaContrattuale','SIIdentifier','TipoFornitura','VersoInserzione','TipoConfigurazione'};
    }
    public class ServizioSISostituzioneRequest_element {
        public String Pod;
        public String SIIdentifier;
        public String NIDIdentifier;
        public String Causale;
        public String IdUtente;
        public String NomeUtente;
        private String[] Pod_type_info = new String[]{'Pod','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] SIIdentifier_type_info = new String[]{'SIIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] NIDIdentifier_type_info = new String[]{'NIDIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Causale_type_info = new String[]{'Causale','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] IdUtente_type_info = new String[]{'IdUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] NomeUtente_type_info = new String[]{'NomeUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Pod','SIIdentifier','NIDIdentifier','Causale','IdUtente','NomeUtente'};
    }
    public class ArrayOfEsitoRicercaType {
        public PED_SmartinfoWSDL.EsitoRicercaType[] EsitoRicerca;
        private String[] EsitoRicerca_type_info = new String[]{'EsitoRicerca','http://xmlns.enel.it/wsdl/smartInfo',null,'1','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'EsitoRicerca'};
    }
    public class EsitoRicercaType {
        public PED_SmartinfoWSDL.FornituraType Fornitura;
        private String[] Fornitura_type_info = new String[]{'Fornitura','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Fornitura'};
    }
    public class DatiAnagraficiType {
        public String CodiceFiscale;
        public String PartitaIva;
        private String[] CodiceFiscale_type_info = new String[]{'CodiceFiscale','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] PartitaIva_type_info = new String[]{'PartitaIva','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'CodiceFiscale','PartitaIva'};
    }
    public class DatiFornituraType {
        public String Pod;
        private String[] Pod_type_info = new String[]{'Pod','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Pod'};
    }
    public class ServizioSIRicerca {
     //public String endpoint_x = 'https://smartinfo.risorse.enel:8013/smartInfo/services/ServizioSIRicerca';
      public String endpoint_x = 'https://4ele-collaudo-wssf.enel.it/smartInfo/services/ServizioSIRicerca';
     // public String endpoint_x = 'https://requestb.in/130albk1';
      
  ;
      
      
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
       private String[] ns_map_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo', 'PED_SmartinfoWSDL'};
        
            public PED_SmartinfoWSDL.ServizioSIRicercaResponse_element ServizioSIRicerca(PED_SmartinfoWSDL.DatiFornituraType DatiFornitura,PED_SmartinfoWSDL.DatiAnagraficiType DatiAnagrafici,PED_SmartinfoWSDL.DatiBaseType DatiBase,String IdUtente,String NomeUtente) {
            PED_SmartinfoWSDL.ServizioSIRicercaRequest_element request_x = new PED_SmartinfoWSDL.ServizioSIRicercaRequest_element();
            system.debug('i am wsdl class');
            request_x.DatiFornitura = DatiFornitura;
            request_x.DatiAnagrafici = DatiAnagrafici;
            request_x.DatiBase = DatiBase;
            request_x.IdUtente = IdUtente;
            request_x.NomeUtente = NomeUtente;
            
            system.debug('the value in the reuuest'+request_x);
             system.debug('Endpoint URL'+endpoint_x );
            
            PED_SmartinfoWSDL.ServizioSIRicercaResponse_element response_x;
            Map<String, PED_SmartinfoWSDL.ServizioSIRicercaResponse_element> response_map_x = new Map<String, PED_SmartinfoWSDL.ServizioSIRicercaResponse_element>();
            response_map_x.put('response_x', response_x);
            
            system.debug('the value'+ response_map_x);
           
            
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://xmlns.enel.it/wsdl/smartInfo/ServizioSIRicerca',
              'http://xmlns.enel.it/wsdl/smartInfo',
              'ServizioSIRicercaRequest',
              'http://xmlns.enel.it/wsdl/smartInfo',
              'ServizioSIRicercaResponse',
              'PED_SmartinfoWSDL.ServizioSIRicercaResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }
    }
}
 
// Custom apex class created me

GLOBAL Class PED_callingsoapservice{
    GLOBAL PED_callingsoapservice()  {
        
        PED_SmartinfoWSDL.DatiBaseType DatiBase =  new PED_SmartinfoWSDL.DatiBaseType();
        PED_SmartinfoWSDL.DatiAnagraficiType DatiAnagrafici = new  PED_SmartinfoWSDL.DatiAnagraficiType();
        DatiAnagrafici.CodiceFiscale='LLLSRG70E09H501O';
        PED_SmartinfoWSDL.DatiFornituraType DatiFornitura = new   PED_SmartinfoWSDL.DatiFornituraType();
        
        DatiFornitura =NULL;
        DatiBase =null;
                
        // PED_SmartinfoWSDL.ServizioSIRicerca obj= new PED_SmartinfoWSDL.ServizioSIRicerca(DatiFornitura , DatiAnagrafici  ,DatiBase ,'TEST','TEST POD');
        PED_SmartinfoWSDL.ServizioSIRicerca obj= new PED_SmartinfoWSDL.ServizioSIRicerca();
        PED_SmartinfoWSDL.ServizioSIRicercaResponse_element res= obj.ServizioSIRicerca(DatiFornitura , DatiAnagrafici  ,DatiBase ,'TEST','TEST POD');
        
        system.debug('Response value'+res);
        
        
        
        
 
    
   }
   }
Prosenjit Sarkar 7Prosenjit Sarkar 7
Hi , 

This trainhead module can help you 

https://trailhead.salesforce.com/en/modules/api_basics/units/api_basics_soap (https://trailhead.salesforce.com/en/modules/api_basics/units/api_basics_soap" target="_blank

Thanks,
Prosenjit