1

I got two Apex classes Generated by wsdl2apex, GetCustomerServiceW and GetCustomerServiceT. I have tried the same WSDL with others SOAP clients on different languages and works fine, but I just can not figure out how to make it to work on Apex with Salesforce. I really appreciate any guidance on how to make the SOAP call to match with the GetCustomerServiceT class types.

In developer console, anonymous window I have tried:

SpectrumCustomersServiceW.GetCustomersPort client = new SpectrumCustomersServiceW.GetCustomersPort();

spectrumCustomersServiceT.returnArray_element customers =  
client.GetCustomers('xxx','xxx','xxx','xxx');

but I get:

System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element getCustomers.

Here below are the classes Generated by wsdl2apex:

public class spectrumCustomersServiceW {
public class GetCustomersPort {
    public String endpoint_x = 'https://dexterchaney.com:8482/ws/GetCustomers';
    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://www.northgate-is.com/proiv/webservices/types', 'spectrumCustomersServiceT', 'http://www.northgate-is.com/proiv/webservices/wsdl', 'spectrumCustomersServiceW'};
    public spectrumCustomersServiceT.returnArray_element GetCustomers(String Authorization_ID,String GUID,String pCompany_Code,String pStatus) {
        spectrumCustomersServiceT.GetCustomers_element request_x = new spectrumCustomersServiceT.GetCustomers_element();
        request_x.Authorization_ID = Authorization_ID;
        request_x.GUID = GUID;
        request_x.pCompany_Code = pCompany_Code;
        request_x.pStatus = pStatus;
        spectrumCustomersServiceT.GetCustomersResponse_element response_x;
        Map<String, spectrumCustomersServiceT.GetCustomersResponse_element> response_map_x = new Map<String, spectrumCustomersServiceT.GetCustomersResponse_element>();
        response_map_x.put('response_x', response_x);
        WebServiceCallout.invoke(
          this,
          request_x,
          response_map_x,
          new String[]{endpoint_x,
          'https://kernsteel.dexterchaney.com:8482/ws/GetCustomers',
          'http://www.northgate-is.com/proiv/webservices/types',
          'GetCustomers',
          'http://www.northgate-is.com/proiv/webservices/types',
          'GetCustomersResponse',
          'spectrumCustomersServiceT.GetCustomersResponse_element'}
        );
        response_x = response_map_x.get('response_x');
        return response_x.returnArray;
     }
   }
  }

Here is the spectrumCustomersServiceT class

public class spectrumCustomersServiceT {
public class GetCustomersResponse_element {
    public spectrumCustomersServiceT.returnArray_element returnArray;
    private String[] returnArray_type_info = new String[]{'returnArray','http://www.northgate-is.com/proiv/webservices/types',null,'1','1','false'};
    private String[] apex_schema_type_info = new String[]{'http://www.northgate-is.com/proiv/webservices/types','false','false'};
    private String[] field_order_type_info = new String[]{'returnArray'};
}
public class GetCustomers_element {
    public String Authorization_ID;
    public String GUID;
    public String pCompany_Code;
    public String pStatus;
    private String[] Authorization_ID_type_info = new String[]{'Authorization_ID','http://www.northgate-is.com/proiv/webservices/types',null,'1','1','false'};
    private String[] GUID_type_info = new String[]{'GUID','http://www.northgate-is.com/proiv/webservices/types',null,'1','1','false'};
    private String[] pCompany_Code_type_info = new String[]{'pCompany_Code','http://www.northgate-is.com/proiv/webservices/types',null,'1','1','false'};
    private String[] pStatus_type_info = new String[]{'pStatus','http://www.northgate-is.com/proiv/webservices/types',null,'1','1','false'};
    private String[] apex_schema_type_info = new String[]{'http://www.northgate-is.com/proiv/webservices/types','false','false'};
    private String[] field_order_type_info = new String[]{'Authorization_ID','GUID','pCompany_Code','pStatus'};
}
public class returnData_element {
    private String[] apex_schema_type_info = new String[]{'http://www.northgate-is.com/proiv/webservices/types','false','false'};
    private String[] field_order_type_info = new String[]{};
}
public class returnArray_element {
    public spectrumCustomersServiceT.returnData_element[] returnData;
    private String[] returnData_type_info = new String[]{'returnData','http://www.northgate-is.com/proiv/webservices/types',null,'0','-1','false'};
    private String[] apex_schema_type_info = new String[]{'http://www.northgate-is.com/proiv/webservices/types','false','false'};
    private String[] field_order_type_info = new String[]{'returnData'};
  }
}

I am being stuck for a while, any help tip, will be highly appreciated.

1 Answer 1

3

Take a look at Daniel Ballinger's post that lists some of the weaknesses of wsdl2apex. (That post is from 2014 but many/most probably still apply.) In my experience you pretty much always have to edit the WSDL with factors like no support for imports being particularly troublesome (that may explain your missing type). That is not easy, as XML Schema (incorporated into WSDL) needs a 300 page book to explain it. And other limitations may stop the generated code working at all.

If at all possible, I suggest you avoid making SOAP calls from Apex. So if your target service also supports JSON/REST patterns, work with those. Apex's support for JSON and raw HTTP calls is pretty good and you are much less likely to run into blocking problems.

1
  • 1
    keith, I really appreciate your input, I will take a look at the suggested post. Sadly the accounting package support on REST is limited, but I will get use where is available.
    – Jose
    Commented Jan 15, 2021 at 19:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .