July 14, 2005 at 10:41 am
Has anyone called a web service from an insert trigger? If so, how did you perform this task?
July 14, 2005 at 11:19 am
Probabely not impossible to do but it would be considered a worst practice. What action do you need to perform in that webservice that can't be handled on the server?
July 14, 2005 at 2:49 pm
Triggers should be used in short (not lengthy ) jobs. You need to re architecture your solution to minimize Trigger time!!
Also can you post what are you trying to accomplish?
* Noel
July 14, 2005 at 2:54 pm
Finally your turn to agree with me .
July 14, 2005 at 2:55 pm
What needs to be accomplished is as new records are added to a database in real time, and address that is submitted needs to be converted to a Lat Long for mapping. I will be using a webservice that converts an address to a Lat Long
July 14, 2005 at 2:58 pm
OK the right approach is that you call the WEB service BEFORE you do the insert! then you don't need the trigger
* Noel
July 14, 2005 at 2:58 pm
You could insert id of the new adresses in the trigger and have some job/service check for new adresses every minute and process them there. How do you calculate that exactly?
July 14, 2005 at 2:59 pm
Even simpler... so I'll agree, again .
3999
July 14, 2005 at 3:02 pm
Can't access web service before entry of data. Data is comming from another outside application, and as records are entered into its database replication is being performed to a database that can be used on the extranet. The data in the extranet is were the LAt Long resides.....
July 14, 2005 at 3:04 pm
Yup, sometimes one has to look at the process as a whole and led the process determine the architecture and not the other way around!!
4000 is for that next AGREE
* Noel
July 14, 2005 at 3:07 pm
Why can't you insert the data. And after it's in, call the webservice from the application?
[EDIT]
Finally came to the Carpal Tunnel stage... now I can take my vacations .
July 14, 2005 at 3:10 pm
>>... replication is being performed to a database that can be used on the extranet. The data in the extranet is were the LAt Long resides..... <<
If you are trying to replicate then just before the distribution agent starts call an app that can fill out those fileds!
A trigger is not the place to do that. If you still insists have a look at sp_OA* and tryit for your self.
1. IT IS CUMBERSOME
2. IT IS SLOW
3. IT IS HARD TO MAINTAIN
4. IT CAN CREATE MANY PROBLEMS WITH MEMORY MANAGEMENT
just my $0.02
* Noel
July 15, 2005 at 2:02 am
By accessing external ressources out of trigger will hold open that specific transaction until the triggers finishes. If an another transaction will try to insert a new record the table may be still locked so your insert may fail. If this is strictly a mono user environment this might be fine but this is not your case as far as I've read.
So I would also opt for a second run after the data is inserted into your table you will have to select regullary (once per min or so) all records having NULL in the LAT, LON columns and so you can invoke the Web Service...
Bye
Gabor
July 15, 2005 at 9:46 am
You could insert id of the new adresses in the
trigger and have some job/service check for new adresses every minute and process them there.
I second Remi's proposed solution. That sounds like the way to do it.
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply