You need to sign in to do that
Don't have an account?
jaden
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.
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
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.
coming to the point when are you calling the method APIParseResponse()? are you sure you are passing the correct argument while calling this method?
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.
Thank you for your time and assistance.
what is the problem that you are currently facing?
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
when you invoke the following method it is returning a result of type wsEdrnetComEnterpriseservicesAbsdata.APIUpdateAccountResult. this is correct
what ever you did after this
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.
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
just take a look at the following method in the webservice class.
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.
one more thing you need to remember is that callout is processed asynchronously and so you cannot check the response immediately.
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.
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.