Partager via


WebPartPagesWebService.GetWebPartProperties - Méthode

Retourne une chaîne XML de tous les WebParts, associé à une Page de composants WebPart.

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

Syntaxe

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

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

Paramètres

  • pageUrl
    Type : System.String

    L'URL de la page contenant le composant WebPart.

Valeur renvoyée

Type : System.Xml.XmlNode
SoapXmlElement Chaîne XML pour tous les WebParts sur une Page de composants WebPart. Cela inclut les GUID, les propriétés de composant WebPart et leurs valeurs, et affiche un aperçu de composant WebPart dans le code HTML.

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 montre une méthode définie localement GetWebPartProperties qui extrait des informations pour tous les WebParts sur une Page de composants WebPart en appelant la méthode GetWebPartProperties du service de Pages de composants WebPart via un proxy. Il affiche ensuite le titre, le GUIDet le type de chacun des WebParts. 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 GetWebPartProperties()
    ' 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"
    ' Use GetWebPartProperties to retreive the ID for one of the Web Parts on the source page
    Dim resultNode As XmlNode = svc.GetWebPartProperties(pageUrl, WebpartpagesSvc.Storage.Shared)
    Console.WriteLine("The following Web Parts were found on page " + ControlChars.Lf + "{0}" + ControlChars.Lf, pageUrl)
    Dim node As XmlNode
    For Each node In  resultNode
        Dim partTitle As String = node("Title").InnerText
        Dim partId As String = node.Attributes("ID").InnerText
        Dim partTypeName As String = node("TypeName").InnerText
            
        Console.WriteLine("Part '{0}' with ID [{1}] " + ControlChars.Lf + ControlChars.Tab + "is of type {2}" + ControlChars.Lf, partTitle, partId, partTypeName)
    Next node 
        Console.WriteLine("-----Hit enter-----")
        Console.ReadLine()
  End Sub 'GetWebPartProperties

  ' XML structure looks like (example of a Contacts Web Part on a page)
  '
  '<SoapXmlElement xmlns="https://microsoft.com/sharepoint/webpartpages">
  '<WebParts>
  '<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" ID="b4523d8e-12f3-410a-99e1-0b915ba90b73">
  '<Title>Contacts</Title> 
  '<FrameType>Default</FrameType> 
  '<Description>Use the Contacts list for information about people that your team works with.</Description> 
  '<IsIncluded>true</IsIncluded> 
  '<ZoneID>LeftColumn</ZoneID> 
  '<PartOrder>1</PartOrder> 
  '<FrameState>Normal</FrameState> 
  '<Height /> 
  '<Width /> 
  '<AllowRemove>true</AllowRemove> 
  '<AllowZoneChange>true</AllowZoneChange> 
  '<AllowMinimize>true</AllowMinimize> 
  '<IsVisible>true</IsVisible> 
  '<DetailLink>http://MyServer/Lists/Contacts/AllItems.aspx</DetailLink> 
  '<HelpLink>http://MyServer/_vti_bin/help/1033/sts/html/dlistwps.htm</HelpLink> 
  '<Dir>Default</Dir> 
  '<PartImageSmall /> 
  '<MissingAssembly /> 
  '<PartImageLarge>http://MyServer/_layouts/images/itcontct.gif</PartImageLarge> 
  '<IsIncludedFilter /> 
  '<ExportControlledProperties>false</ExportControlledProperties> 
  '<ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID> 
  '<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly> 
  '<TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName> 
  '<ListName xmlns="https://schemas.microsoft.com/WebPart/v2/ListView">{199A4AEA-A573-40CB-BB3C-7A66C0375104}</ListName> 
  '<ListViewXml xmlns="https://schemas.microsoft.com/WebPart/v2/ListView">
     '<View Name="{B4523D8E-12F3-410A-99E1-0B915BA90B73}" Type="HTML" Hidden="TRUE" DisplayName="" Url="Shared Documents/SampleStart.aspx" BaseViewID="0">
     '<GroupByHeader><HTML></HTML></Toolbar><ViewFields><FieldRef Name="LinkTitleNoMenu"/><FieldRef Name="FirstName"/>
     '<FieldRef Name="WorkPhone"/><FieldRef Name="Email"/></ViewFields><Query><OrderBy><FieldRef Name="Title"/><FieldRef Name="FirstName"/>
     '</OrderBy></Query></View></ListViewXml> 
  '<ViewFlag xmlns="https://schemas.microsoft.com/WebPart/v2/ListView">9</ViewFlag> 
  '</WebPart>
  '</SoapXmlElement>
private void GetWebPartProperties()
   {
     // 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";
        // Use GetWebPartProperties to retrieve the ID for one of the Web Parts on the source page
        XmlNode resultNode = svc.GetWebPartProperties(pageUrl, WebpartpagesSvc.Storage.Shared);
        Console.WriteLine("The following Web Parts were found on page \n{0}\n", pageUrl);
        foreach(XmlNode node in resultNode)
        {
          string partTitle = node["Title"].InnerText;
          string partId = node.Attributes["ID"].InnerText;
          string partTypeName = node["TypeName"].InnerText;
          Console.WriteLine("Part '{0}' with ID [{1}] \n\tis of type {2}\n", partTitle, partId, partTypeName);

        }
        Console.WriteLine("-----Hit enter-----");
        Console.ReadLine();
        /* XML structure looks like (example of a Contacts Web Part on a page)
          <SoapXmlElement xmlns="https://microsoft.com/sharepoint/webpartpages">
            <WebParts>
              <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" ID="b4523d8e-12f3-410a-99e1-0b915ba90b73">
              <Title>Contacts</Title> 
              <FrameType>Default</FrameType> 
              <Description>Use the Contacts list for information about people that your team works with.</Description> 
              <IsIncluded>true</IsIncluded> 
              <ZoneID>LeftColumn</ZoneID> 
              <PartOrder>1</PartOrder> 
              <FrameState>Normal</FrameState> 
              <Height /> 
              <Width /> 
              <AllowRemove>true</AllowRemove> 
              <AllowZoneChange>true</AllowZoneChange> 
              <AllowMinimize>true</AllowMinimize> 
              <IsVisible>true</IsVisible> 
              <DetailLink>http://MyServer/Lists/Contacts/AllItems.aspx</DetailLink> 
              <HelpLink>http://MyServer/_vti_bin/help/1033/sts/html/dlistwps.htm</HelpLink> 
              <Dir>Default</Dir> 
              <PartImageSmall /> 
              <MissingAssembly /> 
              <PartImageLarge>http://MyServer//_layouts/images/itcontct.gif</PartImageLarge> 
              <IsIncludedFilter /> 
              <ExportControlledProperties>false</ExportControlledProperties> 
              <ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID> 
              <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly> 
              <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName> 
              <ListName xmlns="https://schemas.microsoft.com/WebPart/v2/ListView">{199A4AEA-A573-40CB-BB3C-7A66C0375104}</ListName> 
              <ListViewXml xmlns="https://schemas.microsoft.com/WebPart/v2/ListView">
                    <View Name="{B4523D8E-12F3-410A-99E1-0B915BA90B73}" Type="HTML" Hidden="TRUE" DisplayName="" Url="Shared Documents/SampleStart.aspx" BaseViewID="0">
                    <GroupByHeader><HTML></HTML></Toolbar><ViewFields><FieldRef Name="LinkTitleNoMenu"/><FieldRef Name="FirstName"/>
                    <FieldRef Name="WorkPhone"/><FieldRef Name="Email"/></ViewFields><Query><OrderBy><FieldRef Name="Title"/><FieldRef Name="FirstName"/>
                    </OrderBy></Query></View></ListViewXml> 
              <ViewFlag xmlns="https://schemas.microsoft.com/WebPart/v2/ListView">9</ViewFlag> 
             </WebPart>
           </SoapXmlElement>    
        */    
      }

Voir aussi

Référence

WebPartPagesWebService classe

WebPartPagesWebService - Membres

WebSvcwebpartpages - Espace de noms