You need to sign in to do that
Don't have an account?
SOAP Api Callout
Hello,
I need to make calls to an esternal WebService. I did get their .wsdl and was able to create my class using wsdl2apex.
The services allows me to do a couple of things: Lookup a Client by ID or Create a new Client.
Here's some highlights of what the APEX class looks like. I have some data classes
public class MessageHeader_element {
public String OrganizationName = 'TEST';
public Integer SequenceNumber;
public String UserId;
public String SourceApplication;
public String OrgAlias;
private String[] OrganizationName_type_info = new String[]{'OrganizationName','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] SequenceNumber_type_info = new String[]{'SequenceNumber','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] UserId_type_info = new String[]{'UserId','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] SourceApplication_type_info = new String[]{'SourceApplication','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] OrgAlias_type_info = new String[]{'OrgAlias','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://www.xifin.com/schema/client','true','false'};
private String[] field_order_type_info = new String[]{'OrganizationName','SequenceNumber','UserId','SourceApplication','OrgAlias'};
}
public class StatusType {
public String StatusCode;
public String StatusMessage;
private String[] StatusCode_type_info = new String[]{'StatusCode','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] StatusMessage_type_info = new String[]{'StatusMessage','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://www.xifin.com/schema/client','true','false'};
private String[] field_order_type_info = new String[]{'StatusCode','StatusMessage'};
}
public class Payload_element {
public iRT_XIFIN_Client.StatusType Status;
public iRT_XIFIN_Client.GetClientResponse GetClientResponse;
private String[] Status_type_info = new String[]{'Status','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] GetClientResponse_type_info = new String[]{'GetClientResponse','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://www.xifin.com/schema/client','true','false'};
private String[] field_order_type_info = new String[]{'Status','GetClientResponse'};
}
public class GetClient_element {
public String ClientId;
private String[] ClientId_type_info = new String[]{'ClientId','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://www.xifin.com/schema/client','true','false'};
private String[] field_order_type_info = new String[]{'ClientId'};
}
public class AddClient_element {
public String AccountName;
public iRT_XIFIN_Client.AdditionalStatementCopyType[] AdditionalStatementCopy;
public Boolean BillReferralsToClient;
public iRT_XIFIN_Client.BillingAddressType BillingAddress;
public String ClientAccountType;
public String ClientID;
public String ClientStatementDeliveryMethod;
public String ClientSubmissionServiceId;
public iRT_XIFIN_Client.CorrespondenceAddressType CorrespondenceAddress;
public Boolean DailyCharges;
public String DailyChargesFrequency;
public String DailyChargesNotificationMethod;
public iRT_XIFIN_Client.Questions_element Questions;
public String NPI;
public iRT_XIFIN_Client.POs_element POs;
public String PrimaryFacility;
public iRT_XIFIN_Client.RefundAddress_element RefundAddress;
public Date StartDate;
public String StatementFrequency;
public iRT_XIFIN_Client.BillingAddressType StreetAddress;
public String TaxId;
public iRT_XIFIN_Client.XRefs_element XRefs;
public String CopyClientId;
public Boolean copyBillingAddressToShippingAddress;
public iRT_XIFIN_Client.ShippingAddressType ShippingAddress;
private String[] AccountName_type_info = new String[]{'AccountName','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] AdditionalStatementCopy_type_info = new String[]{'AdditionalStatementCopy','http://www.xifin.com/schema/client',null,'0','-1','false'};
private String[] BillReferralsToClient_type_info = new String[]{'BillReferralsToClient','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] BillingAddress_type_info = new String[]{'BillingAddress','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] ClientAccountType_type_info = new String[]{'ClientAccountType','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] ClientID_type_info = new String[]{'ClientID','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] ClientStatementDeliveryMethod_type_info = new String[]{'ClientStatementDeliveryMethod','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] ClientSubmissionServiceId_type_info = new String[]{'ClientSubmissionServiceId','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] CorrespondenceAddress_type_info = new String[]{'CorrespondenceAddress','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] DailyCharges_type_info = new String[]{'DailyCharges','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] DailyChargesFrequency_type_info = new String[]{'DailyChargesFrequency','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] DailyChargesNotificationMethod_type_info = new String[]{'DailyChargesNotificationMethod','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] Questions_type_info = new String[]{'Questions','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] NPI_type_info = new String[]{'NPI','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] POs_type_info = new String[]{'POs','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] PrimaryFacility_type_info = new String[]{'PrimaryFacility','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] RefundAddress_type_info = new String[]{'RefundAddress','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] StartDate_type_info = new String[]{'StartDate','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] StatementFrequency_type_info = new String[]{'StatementFrequency','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] StreetAddress_type_info = new String[]{'StreetAddress','http://www.xifin.com/schema/client',null,'1','1','false'};
private String[] TaxId_type_info = new String[]{'TaxId','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] XRefs_type_info = new String[]{'XRefs','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] CopyClientId_type_info = new String[]{'CopyClientId','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] copyBillingAddressToShippingAddress_type_info = new String[]{'copyBillingAddressToShippingAddress','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] ShippingAddress_type_info = new String[]{'ShippingAddress','http://www.xifin.com/schema/client',null,'0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://www.xifin.com/schema/client','true','false'};
private String[] field_order_type_info = new String[]{'AccountName','AdditionalStatementCopy','BillReferralsToClient','BillingAddress','ClientAccountType','ClientID','ClientStatementDeliveryMethod','ClientSubmissionServiceId','CorrespondenceAddress','DailyCharges','DailyChargesFrequency','DailyChargesNotificationMethod','Questions','NPI','POs','PrimaryFacility','RefundAddress','StartDate','StatementFrequency','StreetAddress','TaxId','XRefs','CopyClientId','copyBillingAddressToShippingAddress','ShippingAddress'};
}
and a method to invoke the service
public iRT_XIFIN_Client.ResponseMessage_element XIFIN_Request (iRT_XIFIN_Client.MessageHeader_element MessageHeader, iRT_XIFIN_Client.Payload_element Payload) {
// Create a new SOAP Request (will be sent to XIFIN)
iRT_XIFIN_Client.RequestMessage_element request_x = new iRT_XIFIN_Client.RequestMessage_element();
// Create a new SOAP Request Message Header from the parameter
request_x.MessageHeader = MessageHeader;
// Create a new SOAP Request Payload from the parameter
request_x.Payload = Payload;
// Create a new SOAP Response (will receive back from XIFIN)
iRT_XIFIN_Client.ResponseMessage_element response_x;
Map<String, iRT_XIFIN_Client.ResponseMessage_element> response_map_x = new Map<String, iRT_XIFIN_Client.ResponseMessage_element>();
response_map_x.put('response_x', response_x);
// Invoke the SOAP Web Service
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://www.xifin.com/schema/client',
'RequestMessage',
'http://www.xifin.com/schema/client',
'ResponseMessage',
'iRT_XIFIN_Client.ResponseMessage_element'}
);
response_x = response_map_x.get('response_x');
return response_x;
}
The method takes two parameters: MessageHeader_element and Payload_element
I want to be able to call the Get Client service. This is what the Webservice is expecting to receive in my call
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cli="http://www.xifin.com/schema/client" xmlns:msg="http://www.xifin.com/schema/msgHeader">
<soapenv:Header/>
<soapenv:Body>
<cli:RequestMessage>
<msg:MessageHeader>
<!--Optional:-->
<msg:OrganizationName>Demo</msg:OrganizationName>
<!--Optional:-->
<msg:SequenceNumber>123</msg:SequenceNumber>
<msg:UserId>test_user</msg:UserId>
<!--Optional:-->
<msg:OrgAlias>demo</msg:OrgAlias>
</msg:MessageHeader>
<cli:Payload>
<cli:GetClient>
<cli:ClientId>DEOM857612</cli:ClientId>
</cli:GetClient>
</cli:Payload>
</cli:RequestMessage>
</soapenv:Body>
</soapenv:Envelope>
My issue is: how do I add the service to my payload class? It's unclear to me how I construct the code to decide whish service to invoke (Get Client vs. Add Client)
IF you have any idea, I'd really appreciate the help
Thanks
Giorgio
All Answers