Question

I have a web service and a custom logging service class. The logging class has a feature that update or remove itself according to the feature events (Activated=SPService.Update, Deactivating=SPService.Delete).

Can I add or remove the web service as the feature activate/deactivate ?

Was it helpful?

Solution

Adding and removing webservice is not recommended and i don’t think its possible! You have the files in the ISAPI folder as DrFeelgood noted! in the ISAPI contains the wsdl and disco files.

But.... a big but.. you also need the webservice in the GAC folder (assembly). That means if you want to change the webservice to contain methods/remove than you would need to ammend the dll.

That moves me to the project, in your project when you reference to the webservice you would need to update it every time you add/remove.

So short answer is no, well not that i know of ;)

as stated by DrFeelgood, you need to add your dll to GAC, add disco and wsdl to ISAPI folder for discovery (_VTI_Bin) add web reference to your project and use the method that you require accordingly when activating/deactivating!

Is there any reason why you want to do it that way?

EDIT

Ok that makes sense!

in your method within the webservice you need to check for the feature and if its active or deactive, if active (true) carry on and return the result else return false if feature is deactive!

This is to check if the feature is active!

public static myCustomWebservicemethod()
{

     string guidStringFeature = "545646-56454-54665-56464";
     Guid guid = new Guid( guidStringFeature);
     using(SPSite site = new SPSite("url"))
     {
     if(IsFeatureActivated(site ,guid) == true)
     {
          //carry on with the webservice and return the value
          return true;
     }
     }

     //if its deactive than return false (nothing ;))
     return false;
}

public static bool IsFeatureActivated(this SPSite site, Guid featureId)    
{         
    return site.WebApplication.WebService.Fteaures[featureID] != null;    
}     

http://blogs.edwardwilde.com/2009/12/17/programmatically-determine-is-a-feature-is-activated-or-even-installed/

This method is better and less hassle / a method that i would recommend!

OTHER TIPS

What version of SharePoint are you using? I may have some old solutions that I deployed that were SharePoint Web Services I can use as reference to try to help. From what I recall with SharePoint 2010, all you do is deploy it to the ISAPI folder and you should be able to call it in your code.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top