Partager via


WebPartPagesWebService.DeleteWebPart - Méthode

Supprime un composant WebPart dynamique à partir d'une Page de composants WebPart.

Espace de noms :  WebSvcwebpartpages
Assembly :  STSSOAP (dans STSSOAP.dll)

Syntaxe

'Déclaration
<SoapDocumentMethodAttribute("https://microsoft.com/sharepoint/webpartpages/DeleteWebPart", RequestNamespace := "https://microsoft.com/sharepoint/webpartpages",  _
    ResponseNamespace := "https://microsoft.com/sharepoint/webpartpages",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub DeleteWebPart ( _
    pageUrl As String, _
    storageKey As Guid, _
    storage As Storage _
)
'Utilisation
Dim instance As WebPartPagesWebService
Dim pageUrl As String
Dim storageKey As Guid
Dim storage As Storage

instance.DeleteWebPart(pageUrl, storageKey, _
    storage)
[SoapDocumentMethodAttribute("https://microsoft.com/sharepoint/webpartpages/DeleteWebPart", RequestNamespace = "https://microsoft.com/sharepoint/webpartpages", 
    ResponseNamespace = "https://microsoft.com/sharepoint/webpartpages", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void DeleteWebPart(
    string pageUrl,
    Guid storageKey,
    Storage storage
)

Paramètres

  • pageUrl
    Type : System.String

    string qui contient l'URL de la page contenant le composant WebPart.

  • storageKey
    Type : System.Guid

    GUID qui identifie du composant WebPart.

Remarques

La méthode DeleteWebPart est utilisée pour supprimer un composant WebPart. Suppression d'un composant WebPart partagé, lorsque la valeur de stockage personnelles, lèvera l'exception de « Impossible de supprimer le composant WebPart partagé ».

Pour accéder à ses méthodes et le service WebPartPagesWebService , définissez une référence Web à http://Virtual_Server_Name:Port_Number/_vti_adm/WebPartPages.asmx.

Exemples

L'exemple de code suivant montre une méthode définie localement DeleteWebPart qui prend un GUID d'un composant WebPart en tant qu'argument et supprime le composant WebPart d'une Page de composants WebPart en appelant la méthode DeleteWebPart du service de Pages de composants WebPart via un proxy. Cet exemple de code et le proxy font partie d'un exemple plus développé fourni pour le service des Pages de composants WebPart.

Private Sub DeleteWebPart(guidVal As String)
    ' NOTE: The Web Service we are using is defined on MyServer/_vti_bin
    ' Declare and initialize a variable for the WebPartPages Web Service.
    Dim svc = New Microsoft.Samples.WebPartPagesSvcClient.WebpartpagesSvc.WebPartPagesWebService()
         
    ' Authenticate the current user by passing their default
    ' credentials to the Web Service from the system credential cache.
    svc.Credentials = System.Net.CredentialCache.DefaultCredentials
        
    Dim pageUrl As String = "http://MyServer/Shared%20Documents/SampleStart.aspx"
    ' The GUID represents the Web Part ID being deleted
    Dim storageKey As New Guid(guidVal)
    Try
        svc.DeleteWebPart(pageUrl, storageKey, WebpartpagesSvc.Storage.Shared)
            Console.WriteLine("Part [{0}] has been deleted from page [{1}]" + ControlChars.Lf, guidVal, pageUrl)
        Catch er As Exception
            Console.WriteLine("Error: Part [{0}] was not deleted." + ControlChars.Lf + " {1}", guidVal, er.Message)
    End Try
End Sub 'DeleteWebPart
private void DeleteWebPart (string guidVal)
{
    // NOTE: The Web Service we are using is defined on MyServer/_vti_bin.

    // Declare and initialize a variable for the WebPartPages Web Service.
    WebpartpagesSvc.WebPartPagesWebService svc = new Microsoft.Samples.WebPartPagesSvcClient.WebpartpagesSvc.WebPartPagesWebService();
    // Authenticate the current user by passing their default
    // credentials to the Web Service from the system credential cache.
    svc.Credentials = System.Net.CredentialCache.DefaultCredentials;
    string pageUrl = "http://MyServer/Shared%20Documents/SampleStart.aspx";

    // The GUID represents the Web Part ID being deleted.
    Guid storageKey = new Guid(guidVal);  
    try 
    {
        svc.DeleteWebPart(pageUrl, storageKey, WebpartpagesSvc.Storage.Shared);
        Console.WriteLine("Part [{0}] has been deleted from page [{1}]\n", guidVal, pageUrl);
    }
    catch(Exception er)
    {
        Console.WriteLine("Error: Part [{0}] was not deleted.\n {1}", guidVal, er.Message);
    }
}

Format de la demande SOAP   Voici un exemple de demande SOAP 1.1. Le placeholders affichés doivent être remplacés par des valeurs réelles.

POST /_vti_bin/webpartpages.asmx HTTP/1.1
Host: Server_Name
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://microsoft.com/sharepoint/webpartpages/DeleteWebPart"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <DeleteWebPart xmlns="https://microsoft.com/sharepoint/webpartpages">
      <pageUrl>string</pageUrl>
      <storageKey>guid</storageKey>
      <storage>None or Personal or Shared</storage>
    </DeleteWebPart>
  </soap:Body>
</soap:Envelope>

Format de la réponse SOAP   Voici un exemple de réponse SOAP 1.1. Le placeholders indiqué sera remplacé par des valeurs réelles.

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <DeleteWebPartResponse xmlns="https://microsoft.com/sharepoint/webpartpages" />
  </soap:Body>
</soap:Envelope>

Voir aussi

Référence

WebPartPagesWebService classe

WebPartPagesWebService - Membres

WebSvcwebpartpages - Espace de noms