WebPartPagesWebService.GetWebPartCrossPageCompatibility method

Returns connection information for all parts on the target page and compatibility information of the source Web Part with all the parts on a target page, which is used to determine whether Web Parts on two different pages are compatible with each other.

Namespace:  WebSvcwebpartpages
Assembly:  STSSOAP (in STSSOAP.dll)

Syntax

'Declaration
<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
'Usage
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
)

Parameters

  • sourcePageContents
    Type: System.String

    A string containing the source of the .aspx source Web page.

  • targetPageContents
    Type: System.String

    A string containing the source of the .aspx target Web page.

  • providerPartID
    Type: System.String

    A string containing the identifier of a part that resides on the source page.

  • lcid
    Type: System.String

    A locale identifier for locale-specific properties.

Return value

Type: System.String
A string that contains the compatibility information of the providerPartID with all the parts on the target page, along with group and interface information for all the parts on the target page. This string is an XML data island.

Remarks

The arguments identifying the target page and source page are mutually exclusive—provide a value for only one of the two arguments targetPageUrl or targetPageContents, and sourcePageURL or sourcePageContents.

For static Web Parts (not in a Web Part zone), it is possible that the part has an ID (an HTML ID) only, and not a WebPartID (a GUID). In this case, the user can provide the ID as a string to providerPartID. If the static part has only a WebPartID, or both an ID and a WebPartID, then the user must send the WebPartID to the Web Service.

To access the WebPartPagesWebService service and its methods, set a Web reference to http://Virtual_Server_Name:Port_Number/_vti_adm/WebPartPages.asmx.

Examples

The following code example shows a locally defined GetWebPartCrossPageCompatibility method that looks for an Events Web Part in a source Web Part Page, and finds the Web Parts in a target Web Part Page that can connect to the Events Web Part. It does so by calling the GetWebPartProperties and GetWebPartCrossPageCompatibility methods of the WebPartPagesWebService service through a proxy. This code example and the proxy are part of a larger example provided for the WebPartPagesWebService service.

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(); 
      }

See also

Reference

WebPartPagesWebService class

WebPartPagesWebService members

WebSvcwebpartpages namespace