tags:

views:

361

answers:

4

I am forced to use SharePoint web services. I need a web service which will let me delete the SharePoint sub site. I have tried to use DeleteWorkspace method (Meetings.asmx web service), but it is capable of only deleting the sub sites that are meeting workspaces (mine uses a custom template derived from team site). Any help would be appreciated, thanks.

+1  A: 

Unfortunately this isn't possible with the out-of-the-box web services. (They only have functionality for deletion at the site collection level.)

You would need to develop a custom web service and deploy that to your SharePoint farm.

Alex Angas
Thank you for your answer. SharePoint web services suck big time so far.
Boris
+1  A: 

Amazingly! No you can't do it.... I know! weird that it would left out. I'm sure there was a decision made somehwere about but beats me if I know why.

The only option is to deploy custom code - either an event receiver or a web service.

DJ
@DJ: It's not that weird. There's huge amounts of functionality missing in those web services. Anticipating this will be resolved for SharePoint 2010!
Alex Angas
Come on Alex, DeleteSite is there DeleteList etc but the web object is missed? Thats weird in my book.
DJ
@DJ: I think we agree here. Your point is that the web services provide inconsistent functionality. My point is that they miss functionality altogether. End result: they suck.
Alex Angas
Thank you for your answer. SharePoint web services suck big time so far.
Boris
A: 

If you want to delete a site try using the dws webservice.

I used DWS.DeleteDWS() where the functoins get_constant etc simple get back constants for login and webservices like _vti_bin/dws.asmx

Public Function RemoveWSSSite(ByVal sPath As String, ByVal sSubSiteName As String) As Boolean Dim DTConstant As New DTFrameWork.DTConstant Dim SPDWS1 As New SPDws.Dws Dim sSubsiteURL As String = ""

    If (sSubSiteName = "") Then
        sSubsiteURL = ""
    Else
        sSubsiteURL = sSubSiteName & "/"
    End If
    SPDWS1.PreAuthenticate = True
    SPDWS1.Credentials = New System.Net.NetworkCredential(DTconst.Get_Constant_String_Value("SP_m_AdminUser"), DTconst.Get_Constant_String_Value("SP_m_AdminPassword"), DTconst.Get_Constant_String_Value("SP_m_SiteDomain"))
    SPDWS1.Url = DTconst.Get_Constant_String_Value("SP_m_SiteServerName") & IIf(sPath.StartsWith("/"), "", "/") & sPath & IIf(sPath.EndsWith("/"), "", "/") & sSubsiteURL & DTconst.Get_Constant_String_Value("SP_m_dws_asmx")
    Try

        SPDWS1.DeleteDws()

        Return True
    Catch ex As Exception
        Return False
    End Try
End Function
Ben Messneger
A: 

like Ben Says, using /_vti_bin/Dws.asmx should be works. Here's another example

public bool  DeleteSubSite(string urlSubSite, string user, string passw, string domain)
    {
        bool retValue = true;
        Dws docWS = new Dws();
        docWS.Url = urlSubSite + "/_vti_bin/Dws.asmx"; ;
        docWS.Credentials = new System.Net.NetworkCredential(user, passw, domain);

        try
        {
            docWS.DeleteDws();
        }
        catch (SoapException soex)
        {
            retValue = false;
        }
        return retValue;
    }