+ Start a Discussion
e r i c.ax249e r i c.ax249 

Limit Elements Added to Object Array in Proxy Class

I created an Apex class using the "Generate From WSDL" functionality.  One of the methods that is called returns a list of customers from a backend system.  The problem is that certain searches return more than 1000 customers and I receive the "Collection size x,xxx exceeds maximum size of 1,000" error.  How can I limit the number of elements added to the object array that is populated by the response?

Here is the proxy class generated:

//Generated by wsdl2apex

public class companyCsrService {
    public class CommentaryDataRequest {
        public String contractNumber;
        public String sourceSystem;
        private String[] contractNumber_type_info = new String[]{'contractNumber','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] sourceSystem_type_info = new String[]{'sourceSystem','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'contractNumber','sourceSystem'};
    }
    public class AccountResult {
        public companyCsrService.ErrorList errorList;
        public companyCsrService.AccountInfo[] accountInfo;
        private String[] errorList_type_info = new String[]{'errorList','http://www.company.com/CreditSurveillance','ErrorList','0','1','false'};
        private String[] accountInfo_type_info = new String[]{'accountInfo','http://www.company.com/CreditSurveillance','AccountInfo','0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'errorList','accountInfo'};
    }
    public class AccountInfo {
        public Integer customerID{  get; set;  }
        public String customerName{  get; set;  }
        public String pdGrade{  get; set;  }
        public String lgdGrade{  get; set;  }
        public String billingState{  get; set;  }
        public String billingCountry{  get; set;  }
        public String businessSegment{  get; set;  }
        public String businessUnitCode{  get; set;  }
        public String industry{  get; set;  }
        public String sicCode{  get; set;  }
        public String contractID{  get; set;  }
        public String sourceSystem{  get; set;  }
        public String csrUniqueKey{  get; set;  }
        public String plmStatus {  get; set;  }
        private String[] customerID_type_info = new String[]{'customerID','http://www.w3.org/2001/XMLSchema','int','0','1','false'};
        private String[] customerName_type_info = new String[]{'customerName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] pdGrade_type_info = new String[]{'pdGrade','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] lgdGrade_type_info = new String[]{'lgdGrade','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] billingState_type_info = new String[]{'billingState','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] billingCountry_type_info = new String[]{'billingCountry','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] businessSegment_type_info = new String[]{'businessSegment','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] businessUnitCode_type_info = new String[]{'businessUnitCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] industry_type_info = new String[]{'industry','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] sicCode_type_info = new String[]{'sicCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] contractID_type_info = new String[]{'contractID','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] sourceSystem_type_info = new String[]{'sourceSystem','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] csrUniqueKey_type_info = new String[]{'csrUniqueKey','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] plmStatus_type_info = new String[]{'plmStatus','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'customerID','customerName','pdGrade','lgdGrade','billingState','billingCountry','businessSegment','businessUnitCode','industry','sicCode','contractID','sourceSystem','csrUniqueKey'};
    }
    public class CreditSurveillanceSoapQSPort {
        public String endpoint_x = csrConfig.SERVICE_URL;
        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.company.com/CreditSurveillance', 'companyCsrService'};
        public companyCsrService.AccountResult SearchAccount(companyCsrService.SearchAccountRequest searchAccountRequest) {
            companyCsrService.SearchAccount_element request_x = new companyCsrService.SearchAccount_element();
            companyCsrService.SearchAccountResponse_element response_x;
            request_x.searchAccountRequest = searchAccountRequest;
            Map<String, companyCsrService.SearchAccountResponse_element> response_map_x = new Map<String, companyCsrService.SearchAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.company.com/CreditSurveillance/SearchAccount',
              'http://www.company.com/CreditSurveillance',
              'SearchAccount',
              'http://www.company.com/CreditSurveillance',
              'SearchAccountResponse',
              'companyCsrService.SearchAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.accountResponse;
        }
        public companyCsrService.CommentaryDataResponse RetrieveCommentaryData(companyCsrService.CommentaryDataRequest commentaryDataRequest) {
            companyCsrService.RetrieveCommentaryData_element request_x = new companyCsrService.RetrieveCommentaryData_element();
            companyCsrService.RetrieveCommentaryDataResponse_element response_x;
            request_x.commentaryDataRequest = commentaryDataRequest;
            Map<String, companyCsrService.RetrieveCommentaryDataResponse_element> response_map_x = new Map<String, companyCsrService.RetrieveCommentaryDataResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.company.com/CreditSurveillance/RetrieveCommentaryData',
              'http://www.company.com/CreditSurveillance',
              'RetrieveCommentaryData',
              'http://www.company.com/CreditSurveillance',
              'RetrieveCommentaryDataResponse',
              'companyCsrService.RetrieveCommentaryDataResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.commentaryDataResponse;
        }
    }
    public class SearchAccountRequest {
        public Integer customerID;
        public String customerName;
        public String businessUnitCode;
        private String[] customerID_type_info = new String[]{'customerID','http://www.w3.org/2001/XMLSchema','int','0','1','false'};
        private String[] customerName_type_info = new String[]{'customerName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] businessUnitCode_type_info = new String[]{'businessUnitCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'customerID','customerName','businessUnitCode'};
    }
    public class Error {
        public String code;
        public String description;
        private String[] code_type_info = new String[]{'code','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] description_type_info = new String[]{'description','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'code','description'};
    }
    public class CommentaryData {
        public Integer customerId;
        public String contractNumber;
        public String sourceSystem;
        public String effectiveDate;
        public String detailedCommentary;
        public String commentaryType;
        public String createdBy;
        private String[] customerId_type_info = new String[]{'customerId','http://www.w3.org/2001/XMLSchema','int','0','1','false'};
        private String[] contractNumber_type_info = new String[]{'contractNumber','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] sourceSystem_type_info = new String[]{'sourceSystem','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] effectiveDate_type_info = new String[]{'effectiveDate','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] detailedCommentary_type_info = new String[]{'detailedCommentary','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] commentaryType_type_info = new String[]{'commentaryType','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] createdBy_type_info = new String[]{'createdBy','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'customerId','contractNumber','sourceSystem','effectiveDate','detailedCommentary','commentaryType','createdBy'};
    }
    public class CommentaryDataResponse {
        public companyCsrService.ErrorList errorList;
        public companyCsrService.CommentaryData[] commentaryData;
        private String[] errorList_type_info = new String[]{'errorList','http://www.company.com/CreditSurveillance','ErrorList','0','1','false'};
        private String[] commentaryData_type_info = new String[]{'commentaryData','http://www.company.com/CreditSurveillance','CommentaryData','0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'errorList','commentaryData'};
    }
    public class RetrieveCommentaryData_element {
        public companyCsrService.CommentaryDataRequest commentaryDataRequest;
        private String[] commentaryDataRequest_type_info = new String[]{'commentaryDataRequest','http://www.company.com/CreditSurveillance','CommentaryDataRequest','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'commentaryDataRequest'};
    }
    public class SearchAccount_element {
        public companyCsrService.SearchAccountRequest searchAccountRequest;
        private String[] searchAccountRequest_type_info = new String[]{'searchAccountRequest','http://www.company.com/CreditSurveillance','SearchAccountRequest','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'searchAccountRequest'};
    }
    public class SearchAccountResponse_element {
        public companyCsrService.AccountResult accountResponse;
        private String[] accountResponse_type_info = new String[]{'accountResponse','http://www.company.com/CreditSurveillance','AccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'accountResponse'};
    }
    public class RetrieveCommentaryDataResponse_element {
        public companyCsrService.CommentaryDataResponse commentaryDataResponse;
        private String[] commentaryDataResponse_type_info = new String[]{'commentaryDataResponse','http://www.company.com/CreditSurveillance','CommentaryDataResponse','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'commentaryDataResponse'};
    }
    public class ErrorList {
        public companyCsrService.Error[] error;
        private String[] error_type_info = new String[]{'error','http://www.company.com/CreditSurveillance','Error','0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.company.com/CreditSurveillance','true','false'};
        private String[] field_order_type_info = new String[]{'error'};
    }
    
}

 Thanks,
Eric

e r i c.ax249e r i c.ax249

Help....  Not sure if I explained myself clearly but take a look at the SearchAccount method from the code I posted:

 public companyCsrService.AccountResult SearchAccount(companyCsrService.SearchAccountReque​st searchAccountRequest) {
            companyCsrService.SearchAccount_element request_x = new companyCsrService.SearchAccount_element();
            companyCsrService.SearchAccountResponse_element response_x;
            request_x.searchAccountRequest = searchAccountRequest;
            Map<String, companyCsrService.SearchAccountResponse_element> response_map_x = new Map<String, companyCsrService.SearchAccountResponse_element>()​;
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.company.com/CreditSurveillance/SearchAc​count',
              'http://www.company.com/CreditSurveillance',
              'SearchAccount',
              'http://www.company.com/CreditSurveillance',
              'SearchAccountResponse',
              'companyCsrService.SearchAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.accountResponse;
        }

 

Basically:

"response_map_x" contains "response_x" which is of type

"companyCsrService.SearchAccountResponse_element" which contains "accountResponse" of type

"companyCsrService.AccountResult" which contains "accountInfo" of type

"companyCsrService.AccountInfo[]".

 

Can I limit the elements that are getting put into this "accountInfo" array so that I don't get this error?  Can I get around this error some other way?

 

jeremyyjeremyy

Sorry that you haven't received a helpful response. Supposedly as of Apex v18.0, there is no limit on collection size. The current documentation for governor limits reflects this: Understanding Governor Limits. You may want to make sure that you're Apex classes are current version, which is 20.0.

 

If you're still having this problem, you should probably log a case with salesforce.