Share via


WebPartPagesWebService.GetXmlDataFromDataSource Method

Returns XML data from the data source provider.

Namespace:  [Webpartpages Web service]
Web service reference: http://Site/_vti_bin/Webpartpages.asmx

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://microsoft.com/sharepoint/webpartpages/GetXmlDataFromDataSource", RequestNamespace := "https://microsoft.com/sharepoint/webpartpages",  _
    ResponseNamespace := "https://microsoft.com/sharepoint/webpartpages",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function GetXmlDataFromDataSource ( _
    queryXml As String _
) As String
'Usage
Dim instance As WebPartPagesWebService
Dim queryXml As String
Dim returnValue As String

returnValue = instance.GetXmlDataFromDataSource(queryXml)
[SoapDocumentMethodAttribute("https://microsoft.com/sharepoint/webpartpages/GetXmlDataFromDataSource", RequestNamespace = "https://microsoft.com/sharepoint/webpartpages", 
    ResponseNamespace = "https://microsoft.com/sharepoint/webpartpages", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public string GetXmlDataFromDataSource(
    string queryXml
)

Parameters

  • queryXml
    Type: System.String

    A string containing the information to query the data source.

Return Value

Type: System.String
A string that contains the XML results of the query.

Remarks

The GetXmlDataFromDataSource method is only for design time use.

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 query that returns all the fields and data of a list.

Private Sub GetXmlDataFromDataSource()
         
    ' 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
         
    ' Declare a string and initialize it with the query.
    ' list[@id in the string below is unique for each list.
    Dim queryXml As String = "<udc:ConnectionInfo xmlns:udc=""https://schemas.microsoft.com/data/udc"" Purpose=""Query"" UDCVersion=""1.0"" SOAPVersion=""1.0"">" + _
    "<udcs:Location xmlns:udcs=""https://schemas.microsoft.com/data/udc/soap"">STSDataAdapter</udcs:Location>" + _
    "<udcs:SOAPAction xmlns:udcs=""https://schemas.microsoft.com/data/udc/soap"">https://schemas.microsoft.com/sharepoint/dsp/queryRequest</udcs:SOAPAction>" + _
    "<soap:Body xmlns:soap=""https://schemas.xmlsoap.org/soap/envelope/"">" + _
    "<dsp:queryRequest xmlns:dsp=""https://schemas.microsoft.com/sharepoint/dsp"">" + _
    "<dsp:dsQuery resultContent=""dataOnly"" columnMapping=""attribute"" resultRoot=""Rows"" resultRow=""Row"" " + _
       "select=""/list[@id='{199A4AEA-A573-40CB-BB3C-7A66C0375104}']"">" + _
    "<dsp:Query>" + _
    "<dsp:Fields>" + _
    "<dsp:AllFields/>" + _
    "</dsp:Fields>" + _
    "</dsp:Query>" + _
    "</dsp:dsQuery>" + _
    "</dsp:queryRequest>" + _
    "</soap:Body>" + _
    "<soap:Header xmlns:soap=""https://schemas.xmlsoap.org/soap/envelope/"">" + _
    "<dsp:request xmlns:dsp=""https://schemas.microsoft.com/sharepoint/dsp"" document=""content"" method=""query""/>" + _
    "<dsp:versions xmlns:dsp=""https://schemas.microsoft.com/sharepoint/dsp"">" + "<dsp:version>1.0</dsp:version>" + _
    "</dsp:versions>" + _
    "</soap:Header>" + _
    "</udc:ConnectionInfo>"
         
    ' Get the response from the GetXmlDataFromDataSource method.
    Dim response As String = svc.GetXmlDataFromDataSource(queryXml)
         
    Console.WriteLine(response)
         
    Console.WriteLine("-----Hit enter-----")
    Console.ReadLine()
End Sub 'GetXmlDataFromDataSource
private void GetXmlDataFromDataSource()
  {
  
   // 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;

   // Declare a string and initialize it with the query.
   // list[@id in the string below is unique for each list.

   string queryXml = "<udc:ConnectionInfo xmlns:udc=\"https://schemas.microsoft.com/data/udc\" Purpose=\"Query\" UDCVersion=\"1.0\" SOAPVersion=\"1.0\">" +
       "<udcs:Location xmlns:udcs=\"https://schemas.microsoft.com/data/udc/soap\">STSDataAdapter</udcs:Location>" +
       "<udcs:SOAPAction xmlns:udcs=\"https://schemas.microsoft.com/data/udc/soap\">https://schemas.microsoft.com/sharepoint/dsp/queryRequest</udcs:SOAPAction>" +
       "<soap:Body xmlns:soap=\"https://schemas.xmlsoap.org/soap/envelope/\">" + 
       "<dsp:queryRequest xmlns:dsp=\"https://schemas.microsoft.com/sharepoint/dsp\">" + 
       "<dsp:dsQuery resultContent=\"dataOnly\" columnMapping=\"attribute\" resultRoot=\"Rows\" resultRow=\"Row\" " +
       "select=\"/list[@id='{199A4AEA-A573-40CB-BB3C-7A66C0375104}']\">" +
       "<dsp:Query>"+
       "<dsp:Fields>"+
       "<dsp:AllFields/>"+
       "</dsp:Fields>"+
       "</dsp:Query>"+
       "</dsp:dsQuery>"+
       "</dsp:queryRequest>"+
       "</soap:Body>"+
       "<soap:Header xmlns:soap=\"https://schemas.xmlsoap.org/soap/envelope/\">"+
       "<dsp:request xmlns:dsp=\"https://schemas.microsoft.com/sharepoint/dsp\" document=\"content\" method=\"query\"/>"+
       "<dsp:versions xmlns:dsp=\"https://schemas.microsoft.com/sharepoint/dsp\">"+
       "<dsp:version>1.0</dsp:version>"+
       "</dsp:versions>"+
       "</soap:Header>"+
       "</udc:ConnectionInfo>";

   // Get the response from the GetXmlDataFromDataSource method.
   string response = svc.GetXmlDataFromDataSource(queryXml);
 
   Console.WriteLine(response);

   Console.WriteLine("-----Hit enter-----");
   Console.ReadLine();

  }

See Also

Reference

WebPartPagesWebService Class

WebPartPagesWebService Members

Webpartpages Web Service