views:

142

answers:

2

Hello,

I have a class that inherits from SPItemEventReceiver and implements ItemAdded, ItemUpdated, and ItemDeleted. These all work just fine and I'm getting the data I need.

However, I want to push some of the data to a 3rd party server via a web service. What is the best way to configure the external dependency of the web service for various environments (dev/test/production) without hard-coding the end point for each environment?

I'd prefer to avoid any static *.ini type files if possible. Can I add a configuration section to SharePoint's web.config and read it from the event handler?

+1  A: 

Yes, best place to store that settings is web.config file. Below, some related articles:

Rubens Farias
Thanks for the links. The second one worked perfectly for what I'm trying to accomplish.
Mark
+1  A: 

Think of it like that - what would happen if you created yet another site of the same type and having the same event receiver and everything. Would you still use the same configuration? Is it a setting per each list? Per website? Per server farm? If you decide it's a server farm setting, then web.config is good for you. If you think that each web needs different config, then you have to persist the configuration somewhere else. For instance, if it's at web level, you can write your config string to SPWeb.Properties. This setting can later be read easily from that object, for instance SPContext.Current.Web.Properties["RemoteWebServiceURL"]. You can also set the value form a tiny PowerShell script. A SPList object has a similar property bag.

naivists
For further clarification:We have one SharePoint server with one list that we are monitoring and for the production environment, there will be one web service that it communicates with (via the event listener). During development of the web service, however, we have several enviroments (dev/test/uat/production) that I need to be able to switch the SharePoint to communicate with as necessary.It seems like the web.config route is the way to go.
Mark