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
jadenjaden 

Web Service Call

I am working on a callout to a webservice and I am getting an error structuring one of the methods.  The error is happening on this line:

               public static void APIParseResponse(APIUpdateAccountResult XXXAPIResponse) {

 

The error is:

Save error: Invalid type: APIUpdateAccountResult ABSCalloutClass.cls 

 

Here is the wsdl2apex: 

 

//Generated by wsdl2apex

//**********************************************
//BEFORE GOING LIVE CHANGE name from stagews. to ws. 
//**********************************************

public class wsXXXnetComEnterpriseservicesAbsdata {
    public class APIGetAccount_element {
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIUpdateAccount_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer existingCustomer;
        private String[] existingCustomer_type_info = new String[]{'existingCustomer','http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIExistingCustomer','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'existingCustomer'};
    }
    public class APIUpdateAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIAddNewAccountResponse_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResult APIAddNewAccountResult;
        private String[] APIAddNewAccountResult_type_info = new String[]{'APIAddNewAccountResult','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIAddNewAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIAddNewAccountResult'};
    }
    public class APINewCustomer {
        public String CompanyName;
        public String ContactFirstName;
        public String ContactLastName;
        public String Address1;
        public String City;
        public String State;
        public String ZipCode;
        public String Country;
        public String Phone;
        public String Industry;
        private String[] CompanyName_type_info = new String[]{'CompanyName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ContactFirstName_type_info = new String[]{'ContactFirstName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ContactLastName_type_info = new String[]{'ContactLastName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Address1_type_info = new String[]{'Address1','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] City_type_info = new String[]{'City','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] State_type_info = new String[]{'State','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ZipCode_type_info = new String[]{'ZipCode','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Country_type_info = new String[]{'Country','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Phone_type_info = new String[]{'Phone','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[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'CompanyName','ContactFirstName','ContactLastName','Address1','City','State','ZipCode','Country','Phone','Industry'};
    }
    public class SalesForceServiceSoap {
        public String endpoint_x = 'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice.asmx';
        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://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice', 'wsXXXnetComEnterpriseservicesAbsdata'};
        public wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult APIUpdateAccount(wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer existingCustomer) {
            wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccount_element request_x = new wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccount_element();
            wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element response_x;
            request_x.existingCustomer = existingCustomer;
            Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element> response_map_x = new Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x, 
              //For testing the http is http://Stagews.XXXnet	
              //For production the http is http://ws.XXXnet
              'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIUpdateAccount',
              'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIUpdateAccount',
              'http://Stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIUpdateAccountResponse',
              'wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIUpdateAccountResult;
        }
        public wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResult APIAddNewAccount(wsXXXnetComEnterpriseservicesAbsdata.APINewCustomer newCustomer) {
            wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccount_element request_x = new wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccount_element();
            wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element response_x;
            request_x.newCustomer = newCustomer;
            Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element> response_map_x = new Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIAddNewAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIAddNewAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIAddNewAccountResponse',
              'wsXXXnetComEnterpriseservicesAbsdata.APIAddNewAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIAddNewAccountResult;
        }
        public wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResult APIGetAccount() {
            wsXXXnetComEnterpriseservicesAbsdata.APIGetAccount_element request_x = new wsXXXnetComEnterpriseservicesAbsdata.APIGetAccount_element();
            wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element response_x;
            Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element> response_map_x = new Map<String, wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice/APIGetAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIGetAccount',
              'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice',
              'APIGetAccountResponse',
              'wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.APIGetAccountResult;
        }
    }
    public class APIAddNewAccount_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APINewCustomer newCustomer;
        private String[] newCustomer_type_info = new String[]{'newCustomer','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APINewCustomer','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'newCustomer'};
    }
    public class APIAddNewAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class APIUpdateAccountResponse_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult APIUpdateAccountResult;
        private String[] APIUpdateAccountResult_type_info = new String[]{'APIUpdateAccountResult','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIUpdateAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIUpdateAccountResult'};
    }
    public class APIExistingCustomer {
        public String AccountNumber;
        public String Password;
        public String Email;
        public String Address2;
        public String Fax;
        public String AEName;
        public String Initials;
        private String[] AccountNumber_type_info = new String[]{'AccountNumber','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Password_type_info = new String[]{'Password','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Email_type_info = new String[]{'Email','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Address2_type_info = new String[]{'Address2','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Fax_type_info = new String[]{'Fax','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] AEName_type_info = new String[]{'AEName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Initials_type_info = new String[]{'Initials','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'AccountNumber','Password','Email','Address2','Fax','AEName','Initials'};
    }
    public class APIResponse {
        public Boolean Successful;
        public String Message;
        public String Code;
        private String[] Successful_type_info = new String[]{'Successful','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] Message_type_info = new String[]{'Message','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Code_type_info = new String[]{'Code','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','ReturnCodes','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'Successful','Message','Code'};
    }
    public class APIGetAccountResponse_element {
        public wsXXXnetComEnterpriseservicesAbsdata.APIGetAccountResult APIGetAccountResult;
        private String[] APIGetAccountResult_type_info = new String[]{'APIGetAccountResult','http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','APIGetAccountResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{'APIGetAccountResult'};
    }
    public class APIGetAccountResult {
        private String[] apex_schema_type_info = new String[]{'http://stagews.XXXnet.com/enterpriseservices/absdataintegrationservices/salesforceservice','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
}

 Here is the callout class:

 

public class ABSCalloutClass  {

    public static void CallABSWS(Set<Id> idsn){
		list <Account> acctRecs;
		
     	system.debug('In call out class');
     	
         //Creating a List from a SOQL query using idsn
         // Need to add other fields once resolved.
          acctRecs  = 
            [SELECT acc.Id, acc.Name, acc.AccountNumber, acc.XXX_Password__c, acc.Industry,
                (SELECT con.LastName, con.FirstName
                    from Contacts con)          
            FROM Account acc  
            WHERE acc.ID in :Idsn];
            
     	//iterate thru the ids
    	system.debug('The size of acctrecs is ' + acctRecs.size());
    	
    	if (acctRecs.size() == 0)
        	return;  
   
    }   	  
	public void CallUpdateInvokeWebService(Account[] acctRecs) {
             
        for (Account Acct: acctRecs) {
        	
            system.debug('The name is ' + acct.name + ' the number is ' + acct.AccountNumber);
            
            If(trigger.isUpdate) {     
                //Create Instance of service call 
                 wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer XXXCustomer = new
                 wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer();

                 wsXXXnetComEnterpriseservicesAbsdata.APIResponse XXXAPIResponse = new
                 //wsXXXnetComEnterpriseservicesAbsdata.APIResponse();
                  wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult();    
                   
                 XXXCustomer.AccountNumber = acct.AccountNumber;
                
                 XXXCustomer.Password=acct.XXX_Password__c; 
                 //Other fields being needed 
/*               
                Email;
                Address2;
                Fax;
                AEName;
                Initials;               
*/ 
                       
                 wsXXXnetComEnterpriseservicesAbsdata.SalesForceServiceSoap XXXNet = 
                 new wsXXXnetComEnterpriseservicesAbsdata.SalesForceServiceSoap();
                 
                system.debug('about to call update');
                
                  wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult result = 
                 XXXNet.APIUpdateAccount(XXXCustomer);
                 
                 system.debug('back from call update');
            } // If trigger upadte    
        }   //For loop	
	}	
//*	
	@future(callout=true)
	public static void APIParseResponse(APIUpdateAccountResult XXXAPIResponse){ 

        Boolean XXXRespSuccessful;
        String XXXRespMessage;
        String XXXRespCode;

                 //Parse XXXAPIResponse
                XXXRespSuccessful = XXXAPIResponse.Successful;
                XXXRespMessage = XXXAPIResponse.Message;
                XXXRespCode = XXXAPIResponse.Code;
                 
                system.debug('the bool is  '+ XXXRespSuccessful);
                system.debug('the message is ' + XXXRespMessage);
                system.debug('the code is ' + XXXRespCode);

	}
//*/
}

Any help will be greatly appreciated.

Thank you.

Best Answer chosen by Admin (Salesforce Developers) 
jadenjaden

So based on that; since I cannot check right away.

 

Is there a value to checking the repsonse?

 

What is considered best practice?

 

I have another post up under Apex code regarding the call to update and Soap header failure, do you have any suggestions for that?

 

Here is the link:

http://boards.developerforce.com/t5/Apex-Code-Development/Callout-to-webservice-SOAP-Failure/td-p/335765

 

I really appreciate the help with this.

All Answers

SrikanthKuruvaSrikanthKuruva

you should actually use 

@fututre(callout=true)

for the function CallUpdateInvokeWebService because you are doing the actual callout in this method.

 

and the following line of code is not correct i think because APIResponse and APIUpdateAccountResult are 2 different data types.

wsXXXnetComEnterpriseservicesAbsdata.APIResponse XXXAPIResponse = new
                 //wsXXXnetComEnterpriseservicesAbsdata.APIResponse();
                  wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult();

 

coming to the point when are you calling the method APIParseResponse()? are you sure you are passing the correct argument while calling this method?

 

jadenjaden

I did add the @future(callout=True) to the CallupdateInvoke....

 

thank you.

 

I agree that Api response call is incorrect; I am new and I having diificulty with sifting through the pieces.

 

Any help is appreciated.

 

Here is what the class currently looks like; the wsdl has not changes from what I posted already.

 

public class ABSCalloutClass  {

    public static void CallABSWS(Set<Id> idsn){
		list <Account> acctRecs;
		string AccttoUpdateID;
		string ConFirstName;
		string ConLastName;
		string ConEmail;
		string AcctOwner;
		
         //Creating a List from a SOQL query using idsn
          acctRecs  = [SELECT acc.Id, acc.ownerid FROM Account acc WHERE acc.ID in :Idsn];
            
    	system.debug('The size of acctrecs is ' + acctRecs.size());
    	
    	if (acctRecs.size() == 0)
        	return;  
        	
		list<id> owner_ids = new List<id>();
		For(Account a: acctRecs)
		{
			Owner_ids.add(a.OwnerID);
		} 
		Map<id,User> owners = new Map<id,User>([SELECT ID, Name from User WHERE id in :owner_ids]);
		
		list <AccountContactRole> Contacts = 
			[SELECT id, contactId, role, contact.ID, contact.AccountID, contact.FirstName, contact.LastName, contact.Email
			 from AccountContactRole  
			 Where contact.Accountid in :idsn and contact.Primary_Contact__c = :true and (role = 'Billing' or role = 'Accounting' or role = 'Primary')]; 

        //iterate thru the ids	
        for (Account Acct: acctRecs) {	
         	AccttoUpdateID = Acct.Id;
			If(owners.containskey(Acct.Ownerid))
				AcctOwner=owners.get(Acct.Ownerid).Name;
				
         	system.debug('the contacts are ' + Contacts);
         	for (AccountContactRole con: Contacts) { 
         		if (con.contact.AccountID == AccttoUpdateID) {
         			ConFirstName = Con.contact.Firstname;
         			ConLastName = Con.contact.Lastname;
         			ConEmail = Con.contact.Email;
         		}
         	}
         	system.debug('about to invoke call, the account is   ' + AccttoUpdateID + ' and the owner is ' + AcctOwner);
        	CallUpdateInvokeWebService(AccttoUpdateID, ConFirstName, ConLastName, ConEmail, AcctOwner);	
        }
    }  
    @future(callout=true)  	  
	public static void CallUpdateInvokeWebService(String AccttoUpdateID, String ConFirstName, String ConLastName, String ConEmail, string AcctOwner) {
	 	Account AccttoUpdate;
	 	
         // Need to add other fields once resolved.
	 	AccttoUpdate = [SELECT acc.Id, acc.Name, acc.AccountNumber, acc.EDR_Password__c, acc.Industry,
	 					acc.Ownerid, acc.ShippingStreet,acc.Shippingcity, acc.ShippingState, acc.ShippingCountry, acc.ShippingPostalCode,
						acc.BillingStreet,acc.BillingCity, acc.BillingState, acc.BillingCountry, acc.BillingPostalCode
                		//(SELECT con.LastName, con.FirstName, con.Email from Contacts con Where con.Primary_Contact__c = :true)
            			FROM Account acc  
            			WHERE acc.ID = :AccttoUpdateID];
   	
        system.debug('The name is ' + AccttoUpdate.name + ' the number is ' + AccttoUpdate.AccountNumber);
		
        If(trigger.isUpdate) {     
            //Create Instance of service call 
        	wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer edrCustomer = new
            wsEdrnetComEnterpriseservicesAbsdata.APIExistingCustomer();
            
        	wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer edrNewCustomer = new
            wsEdrnetComEnterpriseservicesAbsdata.APINewCustomer();
            
            wsEdrnetComEnterpriseservicesAbsdata.APIResponse edrAPIResponse = new
            wsEdrnetComEnterpriseservicesAbsdata.APIResponse();
                   
            edrCustomer.AccountNumber = AccttoUpdate.AccountNumber;
            edrCustomer.Password=AccttoUpdate.EDR_Password__c; 
            edrNewCustomer.CompanyName = AccttoUpdate.Name; 
			edrNewCustomer.ContactFirstName=ConFirstName;
            
	        edrNewCustomer.ContactLastName = ConLastName;
        	edrNewCustomer.City = AccttoUpdate.BillingCity;
        	edrNewCustomer.State = AccttoUpdate.BillingState;
        	edrNewCustomer.ZipCode = AccttoUpdate.BillingPostalCode;
        	edrNewCustomer.Country = AccttoUpdate.BillingCountry;
        	edrNewCustomer.Phone = AccttoUpdate.Phone;
        	edrNewCustomer.Industry = AccttoUpdate.Industry;
        	edrCustomer.Email = ConEmail;
        	edrCustomer.Fax = AccttoUpdate.Fax;
        	edrCustomer.AEName=AcctOwner;
       		
       		//Split SF Street into 2 fields
       		List<string> address_parts = new List<String>();
			Address_parts=AccttoUpdate.BillingStreet.split('\n');

			If(address_parts.size()>=1)
			  edrNewCustomer.Address1=address_parts[0];
			  
			  system.debug('the address 1 is ' + edrNewCustomer.Address1); 
			  
			If(address_parts.size()>=2)
			  edrCustomer.Address2=address_parts[1];
			  
			  system.debug('the address 2 is ' + edrCustomer.Address2); 
			//If(address_parts.size()>=3)
			//Address3=address_parts[2];
       	
             wsEdrnetComEnterpriseservicesAbsdata.SalesForceServiceSoap edrNet = 
             new wsEdrnetComEnterpriseservicesAbsdata.SalesForceServiceSoap();
                 
             system.debug('about to call update');
               
             wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResult result = 
             edrNet.APIUpdateAccount(edrCustomer);
             system.debug('back from call update'); 
           
              //Call Check Response 
             //APIParseResponse(edrAPIResponse);
             
        } // If trigger upadte    
	}	
/*	
	@future(callout=true)
	public static void APIParseResponse(APIUpdateAccountResponse_element APIUpdateAccountResponse){ 

        Boolean edrRespSuccessful;
        String edrRespMessage;
        String edrRespCode;

        //Parse edrAPIResponse
        edrRespSuccessful = edrAPIResponse.Successful;
        edrRespMessage = edrAPIResponse.Message;
        edrRespCode = edrAPIResponse.Code;
                 
        system.debug('the bool is  '+ edrRespSuccessful);
        system.debug('the message is ' + edrRespMessage);
        system.debug('the code is ' + edrRespCode);
	}
*/
}

 Thank you for your time and assistance.

SrikanthKuruvaSrikanthKuruva

what is the problem that you are currently facing?

jadenjaden

The specific error right now is:

Save error: Invalid type: APIUpdateAccountResponse_element ABSCalloutClass.cls 

 

 

I cannot seem to get syntax for the response method and call to it; snipet below

 

system.debug('back from call update');

 

//Call Check Response

                  APIParseResponse(edrAPIResponse);

 

}

// If trigger upadte

}

@future(callout=true)publicstaticvoidAPIParseResponse(APIUpdateAccountResponse_element APIUpdateAccountResponse){

 

 

Thank you for your help and time

 

SrikanthKuruvaSrikanthKuruva

when you invoke the following method it is returning a result of type wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResult. this is correct

wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResult result = 
             edrNet.APIUpdateAccount(edrCustomer);

 what ever you did after this

APIParseResponse(edrAPIResponse);

 is not at all required and i dont see a need for this. so all you need to do is as soon as your method ABSCalloutClass.CallUpdateInvokeWebService() is called goto setup-->administration setup-->ApexJobs and check whether your method has completed execution. once it is completed check the actual result of the webservice by going to the external system.

jadenjaden

okay, and I understand that I can check this by going to the Apex jobs. 

 

What I am trying to understand as I am new is:

I did not write the webservice, why would someone add a response method if not needed? 

 

In terms of best practices; should it be checked within the code and if so what can be done since it is a callout?

 

thank you

SrikanthKuruvaSrikanthKuruva

just take a look at the following method in the webservice class.

public wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResult APIUpdateAccount(wsXXXnetComEnterpriseservicesAbsdata.APIExistingCustomer existingCustomer) {
            ......
            wsXXXnetComEnterpriseservicesAbsdata.APIUpdateAccountResponse_element response_x;
            ......
            return response_x.APIUpdateAccountResult;
        }

 the last line of this method indicates that it is retruning a value of type 'APIUpdateAccountResult'. But the response_x type is APIUpdateAccountResponse_element . had that some one who has written the webservice to return the response_x instead of response_x.APIUpdateAccountResult, then it would make sense to write the APIParseResponse(...) method in your apexclass.

SrikanthKuruvaSrikanthKuruva

one more thing you need to remember is that callout is processed asynchronously and so you cannot check the response immediately.

jadenjaden

So based on that; since I cannot check right away.

 

Is there a value to checking the repsonse?

 

What is considered best practice?

 

I have another post up under Apex code regarding the call to update and Soap header failure, do you have any suggestions for that?

 

Here is the link:

http://boards.developerforce.com/t5/Apex-Code-Development/Callout-to-webservice-SOAP-Failure/td-p/335765

 

I really appreciate the help with this.

This was selected as the best answer
jadenjaden

It has been pointed out that since this is future checking response may not be valid at this time. I am going to close for now and focus on getting the update method working and then if needed do the response,

 

Thank you to all that replied.