Partager via


WebPartPagesWebService.GetWebPart - Méthode

Retourne les données XML pour un composant WebPart dynamique.

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

Syntaxe

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

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

Paramètres

  • pageurl
    Type : System.String

    Une chaîne contenant l'URL de la page contenant le composant WebPart

  • storageKey
    Type : System.Guid

    Un GUID qui identifie le composant WebPart

Valeur renvoyée

Type : System.String
string contenant le code XML pour un composant WebPart inclure les champs de nom d'assembly et de type.

Remarques

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 illustre une méthode définie localement GetWebPart qui accepte un GUID d'un composant WebPart en tant qu'argument et obtienne des informations sur ce composant WebPart en appelant la méthode GetWebPart du service de Pages de composants WebPart via un proxy. Il affiche ensuite des informations sur le composant WebPart. 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 Function GetWebPart(guidVal As String) 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"
    ' Explain that storagekey is a misnomer, the GUID represents the Web Part ID you are retreiving
    Dim storageKey As New Guid(guidVal)
    Dim result As String = svc.GetWebPart(pageUrl, storageKey, WebpartpagesSvc.Storage.Shared)
    Console.WriteLine("Result is: " + ControlChars.Lf + " {0}" + ControlChars.Lf, result)
    ' result looks like: 
    '
    '    <?xml version=\"1.0\" encoding=\"utf-16\"?>\n
    '    <WebPart xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"     '        xmlns=\"https://schemas.microsoft.com/WebPart/v2\">
    '    <Title>Announcements</Title>
    '    <FrameType>Default</FrameType>
    '    <Description>Use the Announcements list to post messages on the home page of your site.</Description>
    '    <IsIncluded>true</IsIncluded>
    '    <ZoneID>Footer</ZoneID>...
    '    <ListViewXml xmlns=\"https://schemas.microsoft.com/WebPart/v2/ListView\">&lt;View Name=\"{ECF376F0-ACCD-444D-AE50-307E5E547DF5}\" Type=\"HTML\"
    '        Hidden=\"TRUE\" DisplayName=\"\" Url=\"Shared Documents/SampleStart.aspx\" 
    '    BaseViewID=\"0\"&gt;&lt;ViewHeader&gt;&lt;HTML&gt;&lt;![CDATA[&lt;TABLE width=\"100%\" cellspacing=0 cellpadding=0 
    '        border=0&gt;]]&gt;&lt;/HTML&gt;&lt;HTML&gt;&lt;![CDATA[&lt;SCRIPT&gt;\nctx = new ContextInfo();\nctx.listBaseType =
    '        ]]&gt;&lt;/HTML&gt;&lt;ListProperty Select=\"BaseType\"/&gt;&lt;HTML&gt;&lt;![CDATA[;\nctx.listTemplate = ]]&gt;&l
    '    ...
    '
    Return result
End Function 'GetWebPart
private string GetWebPart (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";
        // Explain that storagekey is a misnomer, the GUID represents the Web Part ID you are retreiving
        Guid storageKey = new Guid(guidVal);
        string result = svc.GetWebPart(pageUrl, storageKey, WebpartpagesSvc.Storage.Shared);
        Console.WriteLine("Result is: \n {0}\n",result);
        /* result looks like: 
          <?xml version=\"1.0\" encoding=\"utf-16\"?>\n
          <WebPart xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"https://schemas.microsoft.com/WebPart/v2\">
          <Title>Announcements</Title>
          <FrameType>Default</FrameType>
          <Description>Use the Announcements list to post messages on the home page of your site.</Description>
          <IsIncluded>true</IsIncluded>
          <ZoneID>Footer</ZoneID>...
          <ListViewXml xmlns=\"https://schemas.microsoft.com/WebPart/v2/ListView\">&lt;View Name=\"{ECF376F0-ACCD-444D-AE50-307E5E547DF5}\" Type=\"HTML\" Hidden=\"TRUE\" DisplayName=\"\" Url=\"Shared Documents/SampleStart.aspx\" 
BaseViewID=\"0\"&gt;&lt;ViewHeader&gt;&lt;HTML&gt;&lt;![CDATA[&lt;TABLE width=\"100%\" cellspacing=0 cellpadding=0 
0&gt;]]&gt;&lt;/HTML&gt;&lt;HTML&gt;&lt;![CDATA[&lt;SCRIPT&gt;\nctx = new ContextInfo();\nctx.listBaseType = ]]
gt;&lt;/HTML&gt;&lt;ListProperty Select=\"BaseType\"/&gt;&lt;HTML&gt;&lt;![CDATA[;\nctx.listTemplate = ]]&gt;&l
          ...
        */
        return result;
      }

Voir aussi

Référence

WebPartPagesWebService classe

WebPartPagesWebService - Membres

WebSvcwebpartpages - Espace de noms