This is my first time using WSDL2Apex, or attempting a Callout to a 3rd party API, so please bare with me.
Implementation Goal: Contract is a child-object of Quote. When a new Contract record is created for a Quote, all other Contracts that are associated with that Quote and not Signed should be expired via Webservice Callout to Sertifi's API.
Sertifi's Web Service is accessible via: https://apps.sertifi.net/services/gateway.asmx
The Method I am attempting to use is SetDocumentParameters
- Takes 4 String parameters (APICode,FileID,DocumentID,XMLContent)
- Method Documentation: https://www.sertifi.com/misc/apidocs/webframe.html#Sertifi%20API_ws~r-SetDocumentParameters~o-Method.html
I received a WSDL file from the 3rd party (Sertifi) and followed instructions on how to create Apex classes automatically by uploading the WSDL into Apex Classes. This resulted in 3 classes being created:
- appsSertifiNetServicesLinkparameter
- appsSertifiNetServices
- AsyncAppsSertifiNetServices
Within the appsSertifiNetServices class, I found the portion that I believe I need to send parameters to (I cut out a large portion of this WSDL class that doesn't matter, apologies if the code context is not 100% accurate):
public class appsSertifiNetServices {
public class SetDocumentParametersResponse_element {
public String SetDocumentParametersResult;
private String[] SetDocumentParametersResult_type_info = new String[]{'SetDocumentParametersResult','http://apps.sertifi.net/services/',null,'0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://apps.sertifi.net/services/','true','false'};
private String[] field_order_type_info = new String[]{'SetDocumentParametersResult'};
}
public class SetDocumentParameters_element {
public String p_ApiCode;
public String p_FileID;
public String p_DocumentID;
public String p_XMLContent;
private String[] p_ApiCode_type_info = new String[]{'p_ApiCode','http://apps.sertifi.net/services/',null,'0','1','false'};
private String[] p_FileID_type_info = new String[]{'p_FileID','http://apps.sertifi.net/services/',null,'0','1','false'};
private String[] p_DocumentID_type_info = new String[]{'p_DocumentID','http://apps.sertifi.net/services/',null,'0','1','false'};
private String[] p_XMLContent_type_info = new String[]{'p_XMLContent','http://apps.sertifi.net/services/',null,'0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://apps.sertifi.net/services/','true','false'};
private String[] field_order_type_info = new String[]{'p_ApiCode','p_FileID','p_DocumentID','p_XMLContent'};
}
public String SetDocumentParameters(String p_ApiCode,String p_FileID,String p_DocumentID,String p_XMLContent) {
appsSertifiNetServices.SetDocumentParameters_element request_x = new appsSertifiNetServices.SetDocumentParameters_element();
request_x.p_ApiCode = p_ApiCode;
request_x.p_FileID = p_FileID;
request_x.p_DocumentID = p_DocumentID;
request_x.p_XMLContent = p_XMLContent;
appsSertifiNetServices.SetDocumentParametersResponse_element response_x;
Map<String, appsSertifiNetServices.SetDocumentParametersResponse_element> response_map_x = new Map<String, appsSertifiNetServices.SetDocumentParametersResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://apps.sertifi.net/services/SetDocumentParameters',
'http://apps.sertifi.net/services/',
'SetDocumentParameters',
'http://apps.sertifi.net/services/',
'SetDocumentParametersResponse',
'appsSertifiNetServices.SetDocumentParametersResponse_element'}
);
response_x = response_map_x.get('response_x');
return response_x.SetDocumentParametersResult;
}
}
However, in my code I am trying to do the following in a loop for each contract document:
appsSertifiNetServices.SetDocumentParameters(ApiCode,FileID,DocumentID,XMLContent);
and I receive the following error: Compile Error: Method does not exist or incorrect signature: appsSertifiNetServices.SetDocumentParameters(String, String, String, String) at line 229 column 11
I have never used WSDL2Apex before, and the class created seems slightly different than those that I write on my own so I'm sure I'm not passing this data correctly, but unsure of how I should proceed. What am I doing wrong?
Full Apex Class for those who may want to see it for Troubleshooting:
public without sharing class EContractTriggerHandler {
public EContractTriggerHandler(){
}
public static void expireRelatedDocuments(List<Sertifi2_0__TestContract__c> newContracts){
// Grab APICode from Sertifi Application Settings (Custom Setting)
Sertifi2_0__SertifiSettings__c settings = Sertifi2_0__SertifiSettings__c.getValues('Settings');
String ApiCode = settings.Sertifi2_0__APICode__c;
System.debug('MM++++ ApiCode Echo: ' +ApiCode);
// Create ID set for EContract IDs
Set<Id> QuoteIds = new Set<Id>();
Set<Id> EContractIds = New Set<Id>();
Map<Id,Sertifi2_0__TestContract__c> contractMap = new Map<Id,Sertifi2_0__TestContract__c>();
// Gather EContractID from related Sertifi eContract and add to the ID Set
for(Sertifi2_0__TestContract__c contract : newContracts){
QuoteIds.add(contract.Quote__c);
contractMap.add(contract.Id,contract);
}
List<Sertifi2_0__EDocument__c> eContractList = [SELECT Id,Sertifi2_0__,Sertifi2_0__TestContract__r.Sertifi2_0__ContractID__c,Sertifi2_0__Name__c,Sertifi2_0__Sertifi_ID__c,Sertifi2_0__Status__c
FROM Sertifi2_0__TestContract__c
WHERE Sertifi2_0__TestContract__c IN :EContractIds
AND Sertifi2_0__Status__c != 'Signed'];
if(eDocumentList.size() > 0){
for(Sertifi2_0__EDocument__c edoc : eDocumentList){
String FileID = edoc.Sertifi2_0__TestContract__r.Sertifi2_0__ContractID__c;
String DocumentID = edoc.Sertifi2_0__Sertifi_ID__c;
String XMLContent = '<?xml version="1.0" encoding="UTF-8"?><document><parameter name="changeExpiredStatus" value="expire" />document>';
System.debug('MM++++ ApiCode:' +ApiCode);
System.debug('MM++++ FileID:' +FileID);
System.debug('MM++++ DocumentID:' +documentID);
System.debug('MM++++ XMLContent:' +XMLContent);
appsSertifiNetServices.SetDocumentParameters(ApiCode,FileID,documentID,XMLContent);
}
}
}
}
SetDocumentParameters
is not a static member of the classappsSertifiNetServices
. You need to create object of the classappsSertifiNetServices
and then invoke the method.