You need to sign in to do that
Don't have an account?
Jacobus
Passing parameters to an external web services method
Hi everyone,
I am trying to call a method on an external web service from my apex class and passing a few parameters
The values is passed from a trigger to the class which is successfully received.
My issue is now to pass those values to the external web service method.
Please see my code below and let me know what I am doing wrong here.
Thanks
public with sharing class UpliftmentRequestWebService {
@future (callout=true)
public static void sendvehiclerequest(String dateofrequest, String claimno, String dateoflossformat, String vehiclemodel, String vehicleyear, String vehicleregistrationno, String locationname, String locationcontactperson,
String locationemailaddress, String locationstreetaddress, String locationsuburb, String locationprovince, String customerfirstname, String customerlastname,
String createuserfirstname, String createuserlastname){
system.debug('Date of Request : ' + dateofrequest);
system.debug('Claim No : ' + claimno);
system.debug('Date of Loss : ' + dateoflossformat);
system.debug('Vehicle Model : ' + vehiclemodel);
system.debug('Vehicle Year : ' + vehicleyear);
system.debug('Vehicle Registration No : ' + vehicleregistrationno);
system.debug('Location Name : ' + locationname);
system.debug('Location Contact Person : ' + locationcontactperson);
system.debug('Location Email Address : ' + locationemailaddress);
system.debug('Location Address : ' + locationstreetaddress);
system.debug('Location Suburb : ' + locationsuburb);
system.debug('Location Province : ' + locationprovince);
system.debug('Customer Name : ' + customerfirstname+' '+customerlastname);
system.debug('Create User : ' + createuserfirstname+' '+createuserlastname);
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://releasestest.firstmanagement.co.za/FAMExternalPartyWS.asmx');
req.setCompressed(true); // otherwise we hit a limit of 32000
req.setMethod('POST');
req.setBody('Date of Request='+EncodingUtil.urlEncode(dateofrequest, 'UTF-8')+
'&Claim No='+EncodingUtil.urlEncode(claimno, 'UTF-8')+
'&Date of Loss='+EncodingUtil.urlEncode(dateoflossformat, 'UTF-8')+
'&Vehicle Model='+EncodingUtil.urlEncode(vehiclemodel, 'UTF-8')+
'&Vehicle Year='+EncodingUtil.urlEncode(vehicleyear, 'UTF-8')+
'&Vehicle Registration No='+EncodingUtil.urlEncode(vehicleregistrationno, 'UTF-8')+
'&Location Name='+EncodingUtil.urlEncode(locationname, 'UTF-8')+
'&Location Contact Person='+EncodingUtil.urlEncode(locationcontactperson, 'UTF-8')+
'&Location Email Address='+EncodingUtil.urlEncode(locationemailaddress, 'UTF-8')+
'&Location Address='+EncodingUtil.urlEncode(locationstreetaddress, 'UTF-8')+
'&Location Suburb='+EncodingUtil.urlEncode(locationsuburb, 'UTF-8')+
'&Location Province='+EncodingUtil.urlEncode(locationprovince, 'UTF-8')+
'&Customer First Name='+EncodingUtil.urlEncode(customerfirstname, 'UTF-8')+
'&Customer Last Name='+EncodingUtil.urlEncode(customerlastname, 'UTF-8')+
'&Create User First Name='+EncodingUtil.urlEncode(createuserfirstname, 'UTF-8')+
'&Create User Last Name='+EncodingUtil.urlEncode(createuserlastname, 'UTF-8'));
try {
res = http.send(req);
res.getBody();
}
catch(System.calloutexception e){
system.debug('Callout error has occured : ' + e);
system.debug('RESPONSE :' + res.toString());
system.debug('STATUS : ' + res.getStatus());
system.debug('STATUS_CODE : ' + res.getStatusCode());
}
}
}
I am trying to call a method on an external web service from my apex class and passing a few parameters
The values is passed from a trigger to the class which is successfully received.
My issue is now to pass those values to the external web service method.
Please see my code below and let me know what I am doing wrong here.
Thanks
public with sharing class UpliftmentRequestWebService {
@future (callout=true)
public static void sendvehiclerequest(String dateofrequest, String claimno, String dateoflossformat, String vehiclemodel, String vehicleyear, String vehicleregistrationno, String locationname, String locationcontactperson,
String locationemailaddress, String locationstreetaddress, String locationsuburb, String locationprovince, String customerfirstname, String customerlastname,
String createuserfirstname, String createuserlastname){
system.debug('Date of Request : ' + dateofrequest);
system.debug('Claim No : ' + claimno);
system.debug('Date of Loss : ' + dateoflossformat);
system.debug('Vehicle Model : ' + vehiclemodel);
system.debug('Vehicle Year : ' + vehicleyear);
system.debug('Vehicle Registration No : ' + vehicleregistrationno);
system.debug('Location Name : ' + locationname);
system.debug('Location Contact Person : ' + locationcontactperson);
system.debug('Location Email Address : ' + locationemailaddress);
system.debug('Location Address : ' + locationstreetaddress);
system.debug('Location Suburb : ' + locationsuburb);
system.debug('Location Province : ' + locationprovince);
system.debug('Customer Name : ' + customerfirstname+' '+customerlastname);
system.debug('Create User : ' + createuserfirstname+' '+createuserlastname);
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://releasestest.firstmanagement.co.za/FAMExternalPartyWS.asmx');
req.setCompressed(true); // otherwise we hit a limit of 32000
req.setMethod('POST');
req.setBody('Date of Request='+EncodingUtil.urlEncode(dateofrequest, 'UTF-8')+
'&Claim No='+EncodingUtil.urlEncode(claimno, 'UTF-8')+
'&Date of Loss='+EncodingUtil.urlEncode(dateoflossformat, 'UTF-8')+
'&Vehicle Model='+EncodingUtil.urlEncode(vehiclemodel, 'UTF-8')+
'&Vehicle Year='+EncodingUtil.urlEncode(vehicleyear, 'UTF-8')+
'&Vehicle Registration No='+EncodingUtil.urlEncode(vehicleregistrationno, 'UTF-8')+
'&Location Name='+EncodingUtil.urlEncode(locationname, 'UTF-8')+
'&Location Contact Person='+EncodingUtil.urlEncode(locationcontactperson, 'UTF-8')+
'&Location Email Address='+EncodingUtil.urlEncode(locationemailaddress, 'UTF-8')+
'&Location Address='+EncodingUtil.urlEncode(locationstreetaddress, 'UTF-8')+
'&Location Suburb='+EncodingUtil.urlEncode(locationsuburb, 'UTF-8')+
'&Location Province='+EncodingUtil.urlEncode(locationprovince, 'UTF-8')+
'&Customer First Name='+EncodingUtil.urlEncode(customerfirstname, 'UTF-8')+
'&Customer Last Name='+EncodingUtil.urlEncode(customerlastname, 'UTF-8')+
'&Create User First Name='+EncodingUtil.urlEncode(createuserfirstname, 'UTF-8')+
'&Create User Last Name='+EncodingUtil.urlEncode(createuserlastname, 'UTF-8'));
try {
res = http.send(req);
res.getBody();
}
catch(System.calloutexception e){
system.debug('Callout error has occured : ' + e);
system.debug('RESPONSE :' + res.toString());
system.debug('STATUS : ' + res.getStatus());
system.debug('STATUS_CODE : ' + res.getStatusCode());
}
}
}
Have a question for you! Are you sure whether you should use REST based webservice in this case ? just asking beacuse I see a soap WSDL when i navigate to the endpoint and click Service description!
Thanks,
Balaji
Appreciate your response.
I am a newbie when coming to calling web services and to establish when to use REST or SOAP.
Would very much appreciate it, if you could point me in the right direction.
Perhaps sample code.
Thank you,
1) Consuming SOAP Service
https://help.salesforce.com/HTViewHelpDoc?id=code_wsdl_to_package.htm&language=en_US
2) Consuming REST Service
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm
You can find the call out limitations in the below link:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex_considerations.htm
And one more thing., when i clicked on service description on the link provided by you as endpoint, i noticed it has more than one ports and multiple SOAP bindings, which wsdl to apex functionality wont accept to parse the wsdl.
Not sure if it can solve your problem but definitely helps you!
Thanks,
balaji
Thank you for help, the information provided helped me a lot and definitely in the right direction!!
Regards,
Jacobus
Have another question please, this is my WSDL2APEX class
public class UpliftmentRequestWSDL {
public class GetVehicleModelsByMakeDDLResponse_element {
public UpliftmentRequestWSDL.ArrayOfGenericListItem GetVehicleModelsByMakeDDLResult;
private String[] GetVehicleModelsByMakeDDLResult_type_info = new String[]{'GetVehicleModelsByMakeDDLResult','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://releasestest.firstmanagement.co.za/','true','false'};
private String[] field_order_type_info = new String[]{'GetVehicleModelsByMakeDDLResult'};
}
public static void sendvehiclerequest(String dateofrequest, String claimno, String dateoflossformat, String vehiclemodel, String vehicleyear, String vehicleregistrationno, String locationname, String locationcontactperson,
String locationemailaddress, String locationstreetaddress, String locationsuburb, String locationprovince, String customerfirstname, String customerlastname,
String createuserfirstname, String createuserlastname){
system.debug('Date of Request : ' + dateofrequest);
system.debug('Claim No : ' + claimno);
system.debug('Date of Loss : ' + dateoflossformat);
system.debug('Vehicle Model : ' + vehiclemodel);
system.debug('Vehicle Year : ' + vehicleyear);
system.debug('Vehicle Registration No : ' + vehicleregistrationno);
system.debug('Location Name : ' + locationname);
system.debug('Location Contact Person : ' + locationcontactperson);
system.debug('Location Email Address : ' + locationemailaddress);
system.debug('Location Address : ' + locationstreetaddress);
system.debug('Location Suburb : ' + locationsuburb);
system.debug('Location Province : ' + locationprovince);
system.debug('Customer Name : ' + customerfirstname+' '+customerlastname);
system.debug('Create User : ' + createuserfirstname+' '+createuserlastname);
}
public class ThirdPartyReleaseEntry {
public DateTime DateOfRequest;
public Integer Insurer;
public String ClaimNumber;
public DateTime DateOfLoss;
public Integer VehicleCondition;
public String CustomerSurname;
public String CustomerName;
public String VehicleCommercialPassenger;
public Integer VehicleModelID;
public String VehicleYear;
public String VehicleRegistrationNumber;
public String LocationName;
public String LocationContactPerson;
public String LocationContactNumber;
public String LocationEmailAddress;
public String LocationStreetAddress;
public String LocationSuburb;
public String LocationPostalCode;
public String LocationCity;
public String LocationProvince;
public String SalesForceCapturer;
public String SalesForceReferenceNumber;
private String[] DateOfRequest_type_info = new String[]{'DateOfRequest','http://releasestest.firstmanagement.co.za/',null,'1','1','false'};
private String[] Insurer_type_info = new String[]{'Insurer','http://releasestest.firstmanagement.co.za/',null,'1','1','false'};
private String[] ClaimNumber_type_info = new String[]{'ClaimNumber','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] DateOfLoss_type_info = new String[]{'DateOfLoss','http://releasestest.firstmanagement.co.za/',null,'1','1','false'};
private String[] VehicleCondition_type_info = new String[]{'VehicleCondition','http://releasestest.firstmanagement.co.za/',null,'1','1','false'};
private String[] CustomerSurname_type_info = new String[]{'CustomerSurname','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] CustomerName_type_info = new String[]{'CustomerName','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] VehicleCommercialPassenger_type_info = new String[]{'VehicleCommercialPassenger','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] VehicleModelID_type_info = new String[]{'VehicleModelID','http://releasestest.firstmanagement.co.za/',null,'1','1','false'};
private String[] VehicleYear_type_info = new String[]{'VehicleYear','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] VehicleRegistrationNumber_type_info = new String[]{'VehicleRegistrationNumber','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] LocationName_type_info = new String[]{'LocationName','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] LocationContactPerson_type_info = new String[]{'LocationContactPerson','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] LocationContactNumber_type_info = new String[]{'LocationContactNumber','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] LocationEmailAddress_type_info = new String[]{'LocationEmailAddress','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] LocationStreetAddress_type_info = new String[]{'LocationStreetAddress','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] LocationSuburb_type_info = new String[]{'LocationSuburb','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] LocationPostalCode_type_info = new String[]{'LocationPostalCode','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] LocationCity_type_info = new String[]{'LocationCity','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] LocationProvince_type_info = new String[]{'LocationProvince','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] SalesForceCapturer_type_info = new String[]{'SalesForceCapturer','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] SalesForceReferenceNumber_type_info = new String[]{'SalesForceReferenceNumber','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://releasestest.firstmanagement.co.za/','true','false'};
private String[] field_order_type_info = new String[]{'DateOfRequest','Insurer','ClaimNumber','DateOfLoss','VehicleCondition','CustomerSurname','CustomerName','VehicleCommercialPassenger','VehicleModelID','VehicleYear','VehicleRegistrationNumber','LocationName','LocationContactPerson','LocationContactNumber','LocationEmailAddress','LocationStreetAddress','LocationSuburb','LocationPostalCode','LocationCity','LocationProvince','SalesForceCapturer','SalesForceReferenceNumber'};
}
public class SumbitReleaseFromThirdPartyResponse_element {
public String SumbitReleaseFromThirdPartyResult;
private String[] SumbitReleaseFromThirdPartyResult_type_info = new String[]{'SumbitReleaseFromThirdPartyResult','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://releasestest.firstmanagement.co.za/','true','false'};
private String[] field_order_type_info = new String[]{'SumbitReleaseFromThirdPartyResult'};
}
public class ArrayOfString {
public String[] string_x;
private String[] string_x_type_info = new String[]{'string','http://releasestest.firstmanagement.co.za/',null,'0','-1','true'};
private String[] apex_schema_type_info = new String[]{'http://releasestest.firstmanagement.co.za/','true','false'};
private String[] field_order_type_info = new String[]{'string_x'};
}
public class SumbitReleaseFromThirdParty_element {
public UpliftmentRequestWSDL.ThirdPartyReleaseEntry new_release;
private String[] new_release_type_info = new String[]{'new_release','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://releasestest.firstmanagement.co.za/','true','false'};
private String[] field_order_type_info = new String[]{'new_release'};
}
public class GenericListItem {
public String value;
public String text;
private String[] value_type_info = new String[]{'value','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] text_type_info = new String[]{'text','http://releasestest.firstmanagement.co.za/',null,'0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://releasestest.firstmanagement.co.za/','true','false'};
private String[] field_order_type_info = new String[]{'value','text'};
}
public class ArrayOfGenericListItem {
public UpliftmentRequestWSDL.GenericListItem[] GenericListItem;
private String[] GenericListItem_type_info = new String[]{'GenericListItem','http://releasestest.firstmanagement.co.za/',null,'0','-1','true'};
private String[] apex_schema_type_info = new String[]{'http://releasestest.firstmanagement.co.za/','true','false'};
private String[] field_order_type_info = new String[]{'GenericListItem'};
}
public class SumbitReleaseFromThirdParty{
public String endpoint_x = 'http://releasestest.firstmanagement.co.za/FAMExternalPartyWS.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://releasestest.firstmanagement.co.za/', 'UpliftmentRequestWSDL'};
public String SumbitReleaseFromThirdParty(UpliftmentRequestWSDL.ThirdPartyReleaseEntry new_release) {
UpliftmentRequestWSDL.SumbitReleaseFromThirdParty_element request_x = new UpliftmentRequestWSDL.SumbitReleaseFromThirdParty_element();
request_x.new_release = new_release;
UpliftmentRequestWSDL.SumbitReleaseFromThirdPartyResponse_element response_x;
Map<String, UpliftmentRequestWSDL.SumbitReleaseFromThirdPartyResponse_element> response_map_x = new Map<String, UpliftmentRequestWSDL.SumbitReleaseFromThirdPartyResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://releasestest.firstmanagement.co.za/SumbitReleaseFromThirdParty',
'http://releasestest.firstmanagement.co.za/',
'SumbitReleaseFromThirdParty',
'http://releasestest.firstmanagement.co.za/',
'SumbitReleaseFromThirdPartyResponse',
'UpliftmentRequestWSDL.SumbitReleaseFromThirdPartyResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.SumbitReleaseFromThirdPartyResult;
}
}
}
public String endpoint_x = 'http://releasestest.firstmanagement.co.za/FAMExternalPartyWS.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://releasestest.firstmanagement.co.za/', 'UpliftmentRequestWSDL'};
public String SumbitReleaseFromThirdParty(UpliftmentRequestWSDL.ThirdPartyReleaseEntry new_release) {
UpliftmentRequestWSDL.SumbitReleaseFromThirdParty_element request_x = new UpliftmentRequestWSDL.SumbitReleaseFromThirdParty_element();
request_x.new_release = new_release;
UpliftmentRequestWSDL.SumbitReleaseFromThirdPartyResponse_element response_x;
Map<String, UpliftmentRequestWSDL.SumbitReleaseFromThirdPartyResponse_element> response_map_x = new Map<String, UpliftmentRequestWSDL.SumbitReleaseFromThirdPartyResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://releasestest.firstmanagement.co.za/SumbitReleaseFromThirdParty',
'http://releasestest.firstmanagement.co.za/',
'SumbitReleaseFromThirdParty',
'http://releasestest.firstmanagement.co.za/',
'SumbitReleaseFromThirdPartyResponse',
'UpliftmentRequestWSDL.SumbitReleaseFromThirdPartyResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.SumbitReleaseFromThirdPartyResult;
}
}
DateTime createdate = Date.Today();
String dateofrequest;
String insurer;
String claimno;
DateTime dateofloss;
String dateoflossformat;
String vehiclecondition;
String customerfirstname;
String customerlastname;
String vehiclemodel;
String vehicleyear;
String vehicleregistrationno;
String locationname;
String locationcontactperson;
String locationemailaddress;
String locationstreetaddress;
String locationsuburb;
String locationpostalcode;
String locationcity;
String locationprovince;
String createuserfirstname;
String createuserlastname;
String refno;
id customer;
id vehicleid;
User currentuser=[Select FirstName, LastName from User Where Id =: UserInfo.getUserId() LIMIT 1];
createuserfirstname = currentuser.FirstName;
createuserlastname = currentuser.LastName;
system.debug ('Current User : ' + createuserfirstname +' '+createuserlastname);
for (Vehicle__c v : Trigger.new) {
vehicleid = v.id;
customer = v.Customer__c;
if (v.Insurance_Group__c == 'AFI' || v.Insurance_Group__c == 'Zurich'){
dateofrequest = createdate.format('yyyy/MM/dd');
system.debug('Date of Request : ' + dateofrequest);
if (v.PolicyNo__c != null){
claimno = v.PolicyNo__c;
}
else{
claimno = 'Not Specified';
}
system.debug('Claim No : ' + claimno);
dateofloss = v.Date_Of_Loss__c;
dateoflossformat = dateofloss.format('yyyy/MM/dd');
system.debug('Date of Loss : ' + dateoflossformat);
if (v.Model__c != null){
vehiclemodel = v.Model__c;
}
else{
vehiclemodel = 'Not Specified';
}
system.debug('Vehicle Model : ' + vehiclemodel);
if (v.Reg_Year__c != null){
vehicleyear = v.Reg_Year__c;
}
else{
vehicleyear = 'Not Specified';
}
system.debug('Vehicle Year : ' + vehicleyear);
if(v.RegNo__c != null){
vehicleregistrationno = v.RegNo__c;
}
else{
vehicleregistrationno = 'Not Specified';
}
system.debug('Vehicle Registration No : ' + vehicleregistrationno);
if (v.MBR_Name__c != null){
locationname = v.MBR_Name__c;
}
else {
locationname = 'Not Specified';
}
system.debug('Location Name : ' + locationname);
if (v.MBR_Contact_Person__c != null){
locationcontactperson = v.MBR_Contact_Person__c;
}
else{
locationcontactperson = 'Not Specified';
}
system.debug('Location Contact Person : ' + locationcontactperson);
if (v.MBR_Email__c != null) {
locationemailaddress = v.MBR_Email__c;
}
else {
locationemailaddress = 'Not Specified';
}
system.debug('Location Email Address : ' + locationemailaddress);
if (v.MBR_Address__c != null){
locationstreetaddress = v.MBR_Address__c;
}
else {
locationstreetaddress = 'Not Specified';
}
system.debug('Location Address : ' + locationstreetaddress);
if (v.MBR_Suburb__c != null){
locationsuburb = v.MBR_Suburb__c;
}
else{
locationsuburb = 'Not Specified';
}
system.debug('Location Suburb : ' + locationsuburb);
if (v.MBR_Province__c != null){
locationprovince = v.MBR_Province__c;
}
else {
locationprovince = 'Not Specified';
}
system.debug('Location Province : ' + locationprovince);
}
}
for (Account a : [Select Id, FirstName, LastName from Account where Id =: customer LIMIT 1]) {
if (a.FirstName != null){
customerfirstname = a.FirstName;
}
else {
customerfirstname = 'Not Specified';
}
if (a.LastName != null){
customerlastname = a.LastName;
}
else{
customerlastname = 'Not Specified';
}
system.debug('Customer Name : ' + customerfirstname +' '+ customerlastname);
}
for (Vehicle__c v : Trigger.new) {
if (v.Insurance_Group__c == 'AFI' || v.Insurance_Group__c == 'Zurich'){
try {
system.debug ('About to call the web service class');
//UpliftmentRequestWSDL.sendvehiclerequest(dateofrequest, claimno, dateoflossformat, vehiclemodel, vehicleyear, vehicleregistrationno, locationname, locationcontactperson,
//locationemailaddress, locationstreetaddress, locationsuburb, locationprovince, customerfirstname, customerlastname,
//createuserfirstname, createuserlastname);
UpliftmentRequestWSDL.SumbitReleaseFromThirdParty stub = new UpliftmentRequestWSDL.SumbitReleaseFromThirdParty();
}
catch(DmlException e){
system.debug('The following exception has occured: ' + e.getMessage());
}
}
}
}
String dateofrequest;
String insurer;
String claimno;
DateTime dateofloss;
String dateoflossformat;
String vehiclecondition;
String customerfirstname;
String customerlastname;
String vehiclemodel;
String vehicleyear;
String vehicleregistrationno;
String locationname;
String locationcontactperson;
String locationemailaddress;
String locationstreetaddress;
String locationsuburb;
String locationpostalcode;
String locationcity;
String locationprovince;
String createuserfirstname;
String createuserlastname;
String refno;
UpliftmentRequestWSDL.SumbitReleaseFromThirdParty stub = new UpliftmentRequestWSDL.SumbitReleaseFromThirdParty();
Thanks
https://help.salesforce.com/apex/HTViewSolution?id=000176570&language=en_US
You can not call a webservice method directly from trigger! for which you need an other class to be referenced in the trigger which has Future Annotation (@Future) specified method which invokes the webservice you need. Once you understand this link, we can proceed with the implementation of your requirement.
Thanks,
Balaji
Thank you, I created an extra class with @future.
This works fine.
Below is a web service method that only display a list of values when you call it.
Please advise how to call this method from my @future class?
public UpliftmentRequestWSDL.ArrayOfGenericListItem GetSalesForceInsurersDDL() {
UpliftmentRequestWSDL.GetSalesForceInsurersDDL_element request_x = new UpliftmentRequestWSDL.GetSalesForceInsurersDDL_element();
UpliftmentRequestWSDL.GetSalesForceInsurersDDLResponse_element response_x;
Map<String, UpliftmentRequestWSDL.GetSalesForceInsurersDDLResponse_element> response_map_x = new Map<String, UpliftmentRequestWSDL.GetSalesForceInsurersDDLResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://releasestest.firstmanagement.co.za/GetSalesForceInsurersDDL',
'http://releasestest.firstmanagement.co.za/',
'GetSalesForceInsurersDDL',
'http://releasestest.firstmanagement.co.za/',
'GetSalesForceInsurersDDLResponse',
'UpliftmentRequestWSDL.GetSalesForceInsurersDDLResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.GetSalesForceInsurersDDLResult;
}
}
OK, so I managed to call the GET web service methods in my @future class and also passing the applicable objects......learning lots here :-)
When I call the web services method from my @future class, I now want to see a response to see what is been retrieved from the web service method ?
UpliftmentRequestWSDL.SumbitReleaseFromThirdParty stub = new UpliftmentRequestWSDL.SumbitReleaseFromThirdParty();
stub.GetSalesForceInsurersDDL();
Nice.,
Since the return type for the method GetSalesforceInsurersDDL is UpliftmentRequestWSDL.ArrayOfGenericListItem in the code it will be
Or you also can do:
just to see what you were getting back.,
Try those and let me know.,
Thanks,
balaji
Thank you very much, it works perfect!
This is the return result :
GenericListItem:[apex_schema_type_info=(http://releasestest.firstmanagement.co.za/, true, false),
field_order_type_info=(value, text),
text=ALEXANDER FORBES (PTY)LTD,
text_type_info=(text, http://releasestest.firstmanagement.co.za/, null, 0, 1, false),
value=26, value_type_info=(value, http://releasestest.firstmanagement.co.za/, null, 0, 1, false)],
GenericListItem:[apex_schema_type_info=(http://releasestest.firstmanagement.co.za/, true, false), field_order_type_info=(value, text), text=ZURICH INSURANCE, text_type_info=(text, http://releasestest.firstmanagement.co.za/, null, 0, 1, false), value=347, value_type_info=(value, http://releasestest.firstmanagement.co.za/, null, 0, 1, false)]),
GenericListItem_type_info=(GenericListItem, http://releasestest.firstmanagement.co.za/, null, 0, -1, true), apex_schema_type_info=(http://releasestest.firstmanagement.co.za/, true, false), field_order_type_info=(GenericListItem)]}
The values I am looking to retrieve is the following:
text=ALEXANDER FORBES (PTY)LTD
value=26
AND
text=ZURICH INSURANCE
value=347
Some would be ArrayOfGenericlists and others will be ArrayOfString.
I want to now add these values to a MAP or LIST ?
MAP<string, UpliftmentRequestWSDL.ArrayOfGenericListItem> inmap = new MAP<string, UpliftmentRequestWSDL.ArrayOfGenericListItem>();
inmap.put('response x', insurers);
Any suggestions on this?
Thanks,
Jacobus