Partager via


WebPartPagesWebService.GetWebPartCrossPageCompatibility - Méthode

Retourne les informations de connexion pour toutes les parties sur les informations de compatibilité et de la page cible de la source de toutes les pièces composant WebPart sur une page cible, qui est utilisée pour déterminer si des WebParts sur deux pages différentes sont compatibles entre eux.

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

Syntaxe

'Déclaration
<SoapDocumentMethodAttribute("https://microsoft.com/sharepoint/webpartpages/GetWebPartCrossPageCompatibility", RequestNamespace := "https://microsoft.com/sharepoint/webpartpages",  _
    ResponseNamespace := "https://microsoft.com/sharepoint/webpartpages",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function GetWebPartCrossPageCompatibility ( _
    sourcePageUrl As String, _
    sourcePageContents As String, _
    targetPageUrl As String, _
    targetPageContents As String, _
    providerPartID As String, _
    lcid As String _
) As String
'Utilisation
Dim instance As WebPartPagesWebService
Dim sourcePageUrl As String
Dim sourcePageContents As String
Dim targetPageUrl As String
Dim targetPageContents As String
Dim providerPartID As String
Dim lcid As String
Dim returnValue As String

returnValue = instance.GetWebPartCrossPageCompatibility(sourcePageUrl, _
    sourcePageContents, targetPageUrl, _
    targetPageContents, providerPartID, _
    lcid)
[SoapDocumentMethodAttribute("https://microsoft.com/sharepoint/webpartpages/GetWebPartCrossPageCompatibility", RequestNamespace = "https://microsoft.com/sharepoint/webpartpages", 
    ResponseNamespace = "https://microsoft.com/sharepoint/webpartpages", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public string GetWebPartCrossPageCompatibility(
    string sourcePageUrl,
    string sourcePageContents,
    string targetPageUrl,
    string targetPageContents,
    string providerPartID,
    string lcid
)

Paramètres

  • sourcePageContents
    Type : System.String

    string qui contient la source de la page Web de la source .aspx.

  • targetPageContents
    Type : System.String

    string qui contient la source de la page Web de cible .aspx.

  • providerPartID
    Type : System.String

    string qui contient l'identificateur d'un article qui se trouve dans la page source.

  • lcid
    Type : System.String

    Un identificateur de paramètres régionaux pour les propriétés de paramètres régionaux spécifiques.

Valeur renvoyée

Type : System.String
string qui contient les informations de compatibilité de la providerPartID toutes les pièces dans la page cible, ainsi que des informations de groupe et l'interface pour toutes les parties de la page cible. Cette chaîne est un îlot de données XML.

Remarques

Les arguments qui identifie la cible et source page s'excluent mutuellement : fournir une valeur pour un seul des deux arguments, targetPageUrl ou targetPageContentset sourcePageURL ou sourcePageContents.

Pour WebParts statique (et non dans une zone WebPart), il est possible que la partie possède un ID (un ID HTML) uniquement et pas un WebPartID ( GUID). Dans ce cas, l'utilisateur peut fournir l'ID en tant que chaîne pour providerPartID. Si la partie statique a uniquement un WebPartID, ou un ID et un WebPartID, l'utilisateur doit envoyer le WebPartID au Service Web.

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 GetWebPartCrossPageCompatibility qui recherche un composant WebPart événements dans une Page de composants WebPart source et recherche les WebParts dans une Page de composants WebPart qui peuvent se connecter au composant WebPart événements cible. Il le fait en appelant les méthodes GetWebPartProperties et GetWebPartCrossPageCompatibility du service WebPartPagesWebService via un proxy. Cet exemple de code et le proxy font partie d'un exemple plus développé fourni pour le service WebPartPagesWebService .

Private Sub GetWebPartCrossPageCompatibility()
    ' 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
    ' locId = 1033 for english (based on locale)
    Dim locId As String = "1033"
    Dim sourceUrl, targetUrl As String
    sourceUrl = "http://MyServer/Shared%20Documents/SampleStart.aspx"
    targetUrl = "http://MyServer/Planning/MyPage.aspx"
    ' Use GetWebPartProperties to retreive the ID for one of the Web Parts on the source page.
    Dim resultNode As XmlNode = svc.GetWebPartProperties(sourceUrl, WebpartpagesSvc.Storage.Shared)
    Dim sourcePartId As String = ""
    Dim node As XmlNode
    For Each node In  resultNode
        Dim partTitle As String = node("Title").InnerText
        ' Get the ID for the part that has the string 'Events' in its title.
        If partTitle.StartsWith("Events") Then
            sourcePartId = node.Attributes("ID").InnerText
            Console.WriteLine("Provider List Web Part with ID " + ControlChars.Lf + "[{0}] was found on page " + ControlChars.Lf + "{1}" + ControlChars.Lf, sourcePartId, sourceUrl)
            Exit ForEach
        End If
        Next node 
        Dim responseXml As String = svc.GetWebPartCrossPageCompatibility(sourceUrl, "", targetUrl, "", sourcePartId, locId)
        ' Response is an XML string, read into an XML document for parsing with XPath.
        ' The response XML contains those Web Parts from the Target URL page that support binding to the source part.
        ' For example, retrieve the WebPartIDs for the parts (target) we can bind to.
        Dim xpath As String = "/XML/ConnDesign/ConnectionInfo/WebPart"
        Dim xResponse As New XmlDocument()
        xResponse.LoadXml(responseXml)
        Dim nodeList As XmlNodeList = xResponse.SelectNodes(xpath)
        Console.WriteLine("Connectable WebParts on Target Page:")
        Dim node As XmlNode
        For Each node In  nodeList
            Console.WriteLine("WebPart ID: {0}", node.Attributes("WebPartID").InnerXml)
        Next node
        Dim xpath2 As String = "/XML/ConnDesign/Compatibility/sWebPart/sg/tParts/tWebPart"
        Dim node2 As XmlNode
        Dim xResponse2 As New XmlDocument()
        xResponse2.LoadXml(responseXml)
        Dim nodeList2 As XmlNodeList = xResponse2.SelectNodes(xpath2)
        Console.WriteLine("\nCompatible WebParts on Target Page:")
        For Each node2 in nodeList2
              Console.WriteLine("WebPart ID: {0}", node2.Attributes("WebPartID").InnerXml + " (" +node2.Attributes("title").InnerXml +  ")" )
        Next node2
        Console.WriteLine("-----Hit enter-----")
        Console.ReadLine()
End Sub 'GetWebPartCrossPageCompatibility
private void GetWebPartCrossPageCompatibility ()
     {
       // 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;
       // locId = 1033 for english (based on locale)
       string locId = "1033";
       string sourceUrl, targetUrl;
       sourceUrl = "http://MyServer/Shared%20Documents/SampleStart.aspx";
       targetUrl = "http://MyServer/Planning/MyPage.aspx";
       // Use GetWebPartProperties to retreive the ID for one of the Web Parts on the source page.
       XmlNode resultNode = svc.GetWebPartProperties(sourceUrl, WebpartpagesSvc.Storage.Shared);
       string sourcePartId = "";
       foreach(XmlNode node in resultNode)
       {
         string partTitle = node["Title"].InnerText;
         // Get the ID for the part that has the string 'Events' in its title.
         if (partTitle.StartsWith("Events"))
         {
           sourcePartId=node.Attributes["ID"].InnerText;
           Console.WriteLine("Provider List Web Part with ID \n[{0}] was found on page \n{1}\n", sourcePartId, sourceUrl);
           break;
         }
       }
       string responseXml = svc.GetWebPartCrossPageCompatibility(sourceUrl, "", targetUrl,"", sourcePartId, locId);
       // Response is an XML string, read into an XML document for parsing with XPath.
       // The response XML contains those Web Parts from the Target URL page that support binding to the source part.
       // For example-retrieve the WebPartIDs for the parts (target) we can bind to.
       string xpath = "/XML/ConnDesign/ConnectionInfo/WebPart";
       XmlDocument xResponse = new XmlDocument();
       xResponse.LoadXml(responseXml);
    
       XmlNodeList nodeList = xResponse.SelectNodes(xpath);
       Console.WriteLine("Connectable WebParts on Target Page:");
       foreach(XmlNode node in nodeList)
       {
         Console.WriteLine("WebPart ID: {0}", node.Attributes["WebPartID"].InnerXml);
       }
       string xpath2 = "/XML/ConnDesign/Compatibility/sWebPart/sg/tParts/tWebPart";
       xmlDocument xResponse2 = new XmlDocument();
       xResponse2.LoadXml(responseXml);
       XmlNodeList nodeList2 = xResponse2.SelectNodes(xpath2);
       Console.WriteLine("\nCompatible WebParts on Target Page:");
       foreach(XmlNode node2 in nodeList2)
      {
           Console.WriteLine("WebPart ID: {0}", node2.Attributes["WebPartID"].InnerXml + " (" +node2.Attributes["title"].InnerXml +  ")" );
      }
       Console.WriteLine("-----Hit enter-----");
       Console.ReadLine(); 
      }

Voir aussi

Référence

WebPartPagesWebService classe

WebPartPagesWebService - Membres

WebSvcwebpartpages - Espace de noms