1

I am trying to test the callout from Developer console calling the generated class from WSDL, I am getting following error even though I can see there is no issue in the code because method is accepting two parameters and I am passing exact parameters. But the problem seem to be when those parameters are assigned to the method:

I have tested using soap ui it is working perfectly.Please let me know what error it seems to be.I hope my approach for calling out class is perfect?

'Line: 18, Column: 8 Illegal assignment from BPCreation1.Z_FI_RE_001_DS_0002_Response_element to String'

Developer Console Code:

BPCreation.HTTPS_Port BP=new BPCreation.HTTPS_Port();
BPCreation1.LT_DATA_element data=new BPCreation1.LT_DATA_element();
data.item  = new list<BPCreation1.ZBP_PRTNRDATA>();


BPCreation1.ZBP_PRTNRDATA d1=new BPCreation1.ZBP_PRTNRDATA();
d1.BU_TYPE='2222';
data.item.add(d1);
system.debug('@@@@'+data.item);

BPCreation1.LT_RETURN_element  data1=new BPCreation1.LT_RETURN_element();
data1.item = new list<BPCreation1.ZFIRES006>();
BPCreation1.ZFIRES006  d2=new BPCreation1.ZFIRES006 ();
d2.MANDT='76767';
d2.PARTNER='1111';
data1.item.add(d2);
system.debug('@@'+data1.item);
String output=BP.BusinessPartnerCreation_Request_Sync_Out(data,data1);

Apex Classes Generated from WSDL:

//Generated by wsdl2apex

public class BPCreation {
    public class HTTPS_Port {
        public String endpoint_x = 'XXXX';
        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[]{'urn:sap.com:SALESFORCE:BusinessPartnerCreation', 'BPCreation', 'urn:sap-com:document:sap:rfc:functions', 'BPCreation1'};
        public BPCreation1.Z_FI_RE_001_DS_0002_Response_element BusinessPartnerCreation_Request_Sync_Out(BPCreation1.LT_DATA_element LT_DATA,BPCreation1.LT_RETURN_element LT_RETURN) {
            BPCreation1.Z_FI_RE_001_DS_0002_element request_x = new BPCreation1.Z_FI_RE_001_DS_0002_element();
            request_x.LT_DATA = LT_DATA;
            request_x.LT_RETURN = LT_RETURN;
            BPCreation1.Z_FI_RE_001_DS_0002_Response_element response_x;
            Map<String, BPCreation1.Z_FI_RE_001_DS_0002_Response_element> response_map_x = new Map<String, BPCreation1.Z_FI_RE_001_DS_0002_Response_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://sap.com/xi/WebService/soap1.1',
              'urn:sap-com:document:sap:rfc:functions',
              'Z_FI_RE_001_DS_0002',
              'urn:sap-com:document:sap:rfc:functions',
              'Z_FI_RE_001_DS_0002.Response',
              'BPCreation1.Z_FI_RE_001_DS_0002_Response_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }
    }
} 

Second Class Generated From WSDL :

//Generated by wsdl2apex

public class BPCreation1 {
    public class ZBP_PRTNRADRC {
        public String XDFADR;
        public String CITY1;
        public String CITY2;
        public String POST_CODE1;
        public String STREET;
        public String STR_SUPPL1;
        public String STR_SUPPL2;
        public String STR_SUPPL3;
        public String LOCATION;
        public String COUNTRY;
        public String REGION;
        public String TEL_NUMBER;
        public String FAX_NUMBER;
        public String E_MAIL;
        public String MOB_NUMBER;
        private String[] XDFADR_type_info = new String[]{'XDFADR','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] CITY1_type_info = new String[]{'CITY1','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] CITY2_type_info = new String[]{'CITY2','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] POST_CODE1_type_info = new String[]{'POST_CODE1','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] STREET_type_info = new String[]{'STREET','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] STR_SUPPL1_type_info = new String[]{'STR_SUPPL1','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] STR_SUPPL2_type_info = new String[]{'STR_SUPPL2','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] STR_SUPPL3_type_info = new String[]{'STR_SUPPL3','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] LOCATION_type_info = new String[]{'LOCATION','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] COUNTRY_type_info = new String[]{'COUNTRY','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] REGION_type_info = new String[]{'REGION','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] TEL_NUMBER_type_info = new String[]{'TEL_NUMBER','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] FAX_NUMBER_type_info = new String[]{'FAX_NUMBER','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] E_MAIL_type_info = new String[]{'E_MAIL','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] MOB_NUMBER_type_info = new String[]{'MOB_NUMBER','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions','false','false'};
        private String[] field_order_type_info = new String[]{'XDFADR','CITY1','CITY2','POST_CODE1','STREET','STR_SUPPL1','STR_SUPPL2','STR_SUPPL3','LOCATION','COUNTRY','REGION','TEL_NUMBER','FAX_NUMBER','E_MAIL','MOB_NUMBER'};
    }
    public class Z_FI_RE_001_DS_0002_element {
        public BPCreation1.LT_DATA_element LT_DATA;
        public BPCreation1.LT_RETURN_element LT_RETURN;
        private String[] LT_DATA_type_info = new String[]{'LT_DATA','urn:sap-com:document:sap:rfc:functions',null,'1','1','false'};
        private String[] LT_RETURN_type_info = new String[]{'LT_RETURN','urn:sap-com:document:sap:rfc:functions',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions','false','false'};
        private String[] field_order_type_info = new String[]{'LT_DATA','LT_RETURN'};
    }
    public class EX_T_BP_NO_element {
        public String[] item;
        private String[] item_type_info = new String[]{'item','urn:sap-com:document:sap:rfc:functions',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions','false','false'};
        private String[] field_order_type_info = new String[]{'item'};
    }
    public class LT_DATA_element {
        public BPCreation1.ZBP_PRTNRDATA[] item;
        private String[] item_type_info = new String[]{'item','urn:sap-com:document:sap:rfc:functions',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions','false','false'};
        private String[] field_order_type_info = new String[]{'item'};
    }
    public class ZBP_PRTNRDATA {
        public String PARTNER;
        public String BU_TYPE;
        public String RLTYP;
        public String BU_SORT1;
        public String BU_SORT2;
        public String TITLE;
        public String NAME_LAST;
        public String NAME_FIRST;
        public String SEX_M;
        public String SEX_F;
        public String BIRTHDATE;
        public String MARRIAGE_STATE;
        public String EMPLO;
        public String JOB_GROUP;
        public String NATIO;
        public String COUNTRY_DESC;
        public String TITLELETTER;
        public String ZZFILENO;
        public String ZZNAME;
        public String ZZSANAMOUNT;
        public String ZZNAMEASSL;
        public String ZZNATION;
        public String ZZCOMP_REGNO;
        public String ZZPAN_NO;
        public String ZZNRI_RES;
        public String BUKRS;
        public String KATR1;
        public String ZUAWA;
        public String AKONT;
        public String ZWELS;
        public String ZTERM;
        public String VZSKZ;
        public String ZINRT;
        public String MGRUP;
        public String KUNNR;
        public String MABER;
        public String MAHNA;
        public String MANSP;
        public String MAHNS;
        public BPCreation1.ZBP_I_PRTNRADRC I_ADRC;
        private String[] PARTNER_type_info = new String[]{'PARTNER','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] BU_TYPE_type_info = new String[]{'BU_TYPE','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] RLTYP_type_info = new String[]{'RLTYP','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] BU_SORT1_type_info = new String[]{'BU_SORT1','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] BU_SORT2_type_info = new String[]{'BU_SORT2','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] TITLE_type_info = new String[]{'TITLE','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] NAME_LAST_type_info = new String[]{'NAME_LAST','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] NAME_FIRST_type_info = new String[]{'NAME_FIRST','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] SEX_M_type_info = new String[]{'SEX_M','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] SEX_F_type_info = new String[]{'SEX_F','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] BIRTHDATE_type_info = new String[]{'BIRTHDATE','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] MARRIAGE_STATE_type_info = new String[]{'MARRIAGE_STATE','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] EMPLO_type_info = new String[]{'EMPLO','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] JOB_GROUP_type_info = new String[]{'JOB_GROUP','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] NATIO_type_info = new String[]{'NATIO','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] COUNTRY_DESC_type_info = new String[]{'COUNTRY_DESC','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] TITLELETTER_type_info = new String[]{'TITLELETTER','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZZFILENO_type_info = new String[]{'ZZFILENO','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZZNAME_type_info = new String[]{'ZZNAME','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZZSANAMOUNT_type_info = new String[]{'ZZSANAMOUNT','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZZNAMEASSL_type_info = new String[]{'ZZNAMEASSL','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZZNATION_type_info = new String[]{'ZZNATION','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZZCOMP_REGNO_type_info = new String[]{'ZZCOMP_REGNO','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZZPAN_NO_type_info = new String[]{'ZZPAN_NO','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZZNRI_RES_type_info = new String[]{'ZZNRI_RES','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] BUKRS_type_info = new String[]{'BUKRS','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] KATR1_type_info = new String[]{'KATR1','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZUAWA_type_info = new String[]{'ZUAWA','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] AKONT_type_info = new String[]{'AKONT','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZWELS_type_info = new String[]{'ZWELS','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZTERM_type_info = new String[]{'ZTERM','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] VZSKZ_type_info = new String[]{'VZSKZ','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] ZINRT_type_info = new String[]{'ZINRT','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] MGRUP_type_info = new String[]{'MGRUP','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] KUNNR_type_info = new String[]{'KUNNR','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] MABER_type_info = new String[]{'MABER','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] MAHNA_type_info = new String[]{'MAHNA','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] MANSP_type_info = new String[]{'MANSP','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] MAHNS_type_info = new String[]{'MAHNS','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] I_ADRC_type_info = new String[]{'I_ADRC','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions','false','false'};
        private String[] field_order_type_info = new String[]{'PARTNER','BU_TYPE','RLTYP','BU_SORT1','BU_SORT2','TITLE','NAME_LAST','NAME_FIRST','SEX_M','SEX_F','BIRTHDATE','MARRIAGE_STATE','EMPLO','JOB_GROUP','NATIO','COUNTRY_DESC','TITLELETTER','ZZFILENO','ZZNAME','ZZSANAMOUNT','ZZNAMEASSL','ZZNATION','ZZCOMP_REGNO','ZZPAN_NO','ZZNRI_RES','BUKRS','KATR1','ZUAWA','AKONT','ZWELS','ZTERM','VZSKZ','ZINRT','MGRUP','KUNNR','MABER','MAHNA','MANSP','MAHNS','I_ADRC'};
    }
    public class Z_FI_RE_001_DS_0002_Response_element {
        public BPCreation1.EX_T_BP_NO_element EX_T_BP_NO;
        public BPCreation1.LT_RETURN_element LT_RETURN;
        private String[] EX_T_BP_NO_type_info = new String[]{'EX_T_BP_NO','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] LT_RETURN_type_info = new String[]{'LT_RETURN','urn:sap-com:document:sap:rfc:functions',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions','false','false'};
        private String[] field_order_type_info = new String[]{'EX_T_BP_NO','LT_RETURN'};
    }
    public class LT_RETURN_element {
        public BPCreation1.ZFIRES006[] item;
        private String[] item_type_info = new String[]{'item','urn:sap-com:document:sap:rfc:functions',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions','false','false'};
        private String[] field_order_type_info = new String[]{'item'};
    }
    public class ZFIRES006 {
        public String MANDT;
        public String PARTNER;
        public String MESSAGE1;
        public String MESSAGE2;
        private String[] MANDT_type_info = new String[]{'MANDT','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] PARTNER_type_info = new String[]{'PARTNER','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] MESSAGE1_type_info = new String[]{'MESSAGE1','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] MESSAGE2_type_info = new String[]{'MESSAGE2','urn:sap-com:document:sap:rfc:functions',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions','false','false'};
        private String[] field_order_type_info = new String[]{'MANDT','PARTNER','MESSAGE1','MESSAGE2'};
    }
    public class ZBP_I_PRTNRADRC {
        public BPCreation1.ZBP_PRTNRADRC[] item;
        private String[] item_type_info = new String[]{'item','urn:sap-com:document:sap:rfc:functions',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:sap-com:document:sap:rfc:functions','false','false'};
        private String[] field_order_type_info = new String[]{'item'};
    }
}
1

You need to use something like the following:

String response = 
  BP
    .BusinessPartnerCreation_Request_Sync_Out(data,data1)
    .LT_RETURN
    .item[0]
    .MESSAGE1;

Basically, you have to navigate through the data structure to get to the actual message.

If you're not sure what data you need, I suggest using a checkpoint or debug messages to figure out the correct data structure.

  • Hi sfdcfox, thanks for the response I didn't understand why you did that, can you explain apart from the two parameters you are also returning other things how will I be able to code in apex dynamically can you share small snippet for above thing if possible...after using your snippet I am also getting this error "Line: 20, Column: 1 System.CalloutException: IO Exception: java.security.cert.CertificateException: No subject alternative names matching IP address 14.142.48.65 found" – Salesforce Learner Jan 15 '17 at 4:37
  • @SalesforceLearner For the callout error, it's saying that your certificate is invalid. Make sure you have a domain set up, and have a certificate for the domain. It looks like you're connecting directly to an IP address. For the former question, your callout method returns an object `BPCreation1.Z_FI_RE_001_DS_0002_Response_element, which contains a LT_RETURN member, which in turn has an array called item, each of which has four elements, including a MESSAGE1 and MESSAGE2. Apex isn't good at dynamic WSDL binding; you need to learn how to navigate the data structures. – sfdcfox Jan 15 '17 at 5:34
  • Hi SFDC Fox,thanks for the response you can see my code wsdl is not allowing me to pass credential I mean User name and password how do i set up that? – Salesforce Learner Jan 16 '17 at 9:31
  • Class generated from WSDL does not have the user name and password where as in SOAP UI I am passing that? – Salesforce Learner Jan 16 '17 at 9:32
  • @SalesforceLearner See SOAP Services: Defining a Class from a WSDL Document; they go over that in more detail. The specifics are going to be related to your service's authentication method, so you may also need to consult the manual for that specific service. – sfdcfox Jan 16 '17 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.