0
votes

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.

5

5 Answers

1
votes

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.

1
votes

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.

1
votes

If you upgrade to SharePoint 2013, there is a new method in the Sites web service: DeleteWeb. It expects URL of the subsite to delete, relative to the site that you connected the web service to.

--- Ferda

0
votes

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;
    }
0
votes

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