You need to sign in to do that
Don't have an account?

Calling a Web Service using Trigger
Hi
Can we call a web service class using a trigger?please provide me with some examples as i am new to apex and just trying to explore it..
Any help in this regard is kindly appreciated.
regards,
Hello,
Webservice cannot be called directly from a trigger.
There is special type of method called as future method, declared using future annotation as:
@future (callout= true)
public static void sampleMethod()
The speciality of this method is that it accepts only primitive data type as arguments i.e. String, Double /List or Set of the same and arguments such a Account, Contact or any collection of the same is not accepted.
So the webservice callout logic needs to placed in a future method and the future method needs to be called from the trigger.
Future method execute in different context that is why we can make callout, it does execute in same context as trigger i.e. asynchronous.
Regards,
PP