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
Anto HotelbedsAnto Hotelbeds 

Invoking a webservice with Apex

Hi,

 

I have to call to an external webservice everytime a new account is created. My question is, what is the best way to do so?

 

I thougt about creating an after create trigger that will invoke the method in the class that was generated from the WSDL import. Would that make sense?

 

If so, how can I import a class into a trigger to use its methods?

 

Thanks a lot. Regards,

 

Antonio

Best Answer chosen by Admin (Salesforce Developers) 
stan_sfdcstan_sfdc

You can define a method in a class which can be invoked from a triggger. If you have a WSDL, you can populate the data as per the XSD and it will be delivered to the endpoint. 

 

Note - You can always use the out of the box 'Outbound Messaging' in this case.