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
zirosziros 

Calling to external Web Service from salesforce scenario (please help)

Hello
 
I have a need to call to external Web Service (asp.net) to do some work from sales force.
The scenario that I have is:
 
From Opportunity Object when saved, I need to call the external web service and pass it data , but not only from
opportunity but from many object Like contact, ContactRoles, Account and more... I'm gathering my data with SOQL,
and passing the data as a class to the asp.net web service.
 
The best solution for me was to call This web service from a Trigger, but that is not supported by salesforce !
 
so the other method I know of are:
 
1)  Creating a Scontrol button this button will call an apex class which wil call the Web Service.
     This technique is working but far from be sufficeint in my case.
      Becuase save button can't be overide so It leaves the user the choice to press that button or not, which is not good.
      Maybe there is a workaround for that ??
 
2) Creating workflow on Opportunity which will call an outbound message when a save occure.
    I guess this will work too, but I have from start couple of problems.. or lack of knowledge.
 
    a) It stated that if the outbound message could not be delivered after 24H the message dropped from the queue.
        which is not good at all for the case I work for...
    b) when defining an outbound message there is a need to choose what fields to pass, "Fields to send"
        but what if I need to pass many fields and not just from the Opportunity object ? can it be done ?
 
 
Thanks for any help on this
 
David VPDavid VP
1) If I'm not mistaken calling a webservice from a trigger is now supported if you use @future annotations (has some drawbacks of it's own but see if you can work with that)
2) a) If your message can not be delivered after 24 hours then you have more serious problems : do you really expect your 'listening web service' to be down for 24 hours ?
b) The outbound message is limited to the fields of the object on which you define them. You can however use this outbound message to trigger your external webservice which will then via the API 'call back' and retrieve all extra information it needs. The outbound message can include a session id that you can use to connect.


Hope this helps,


-David


zirosziros

HI David thx for answering !

Im not familier with the @future annotations , can u direct me to some info about it.

about b) I thought about that kind of solution but for now if there is  a hope for trigger I would like to try this first.

thank !!

David VPDavid VP
You can find about it in the Apex docs. Search for 'annotations'.

Read that first and see if it fits your needs.



-David