SoapDataSource Class
System.Object
System.Web.UI.Control
System.Web.UI.HierarchicalDataSourceControl
Microsoft.SharePoint.WebControls.BaseXmlDataSource
Microsoft.SharePoint.WebControls.SoapDataSource
System.Web.UI.Control
System.Web.UI.HierarchicalDataSourceControl
Microsoft.SharePoint.WebControls.BaseXmlDataSource
Microsoft.SharePoint.WebControls.SoapDataSource
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
SoapDataSource
Description
The Microsoft.SharePoint.WebControls.SoapDataSource inherits from the Microsoft.SharePoint.WebControls.BaseXmlDataSource and implements the System.Web.UI.IDataSource interface. SoapDataSource’s main purpose is to build a web service sponsored abstracted datasource that data-bound controls can bind to.
In order to support arbitrary web service calls, SoapDataSource acts as a wrapper class. Taking in particular web service parameters, the output will allow you to set the DataSource property in a data-bound control to a hydrated SoapDataSource object.
In order to hydrate a new SoapDataSource object, there are some web services centric properties of the SoapDataSource object that must provided.
SoapDataSource.SelectServiceName – String representation of the friendly name of the web service.
SoapDataSource.SelectUrl – String representation of the complete URL to the web service. This can be somewhat abstracted by introducing proxy objects such as SPContext.Current.Site.Rootweb.Url to get a base location coupled with a constant deployment directory for web services.
SoapDataSource.WsdlPath – String representation of the complete URL to the web service WSDL file. The WSDL contains the model for describing the web service. This is commonly the SPDataSource.SelectUrl + “?WSDL”.
SoapDataSource.SelectPort – String representation of the exact web service SOAP protocol name
SoapDataSource.SelectAction – String representation of the action name called from the web service to execute data operations.
SoapDataSource.SelectCommand – String representation of the SOAP select command that will send XML queries and send responses via HTTP. Within the XML body element you will find the method call and parameters.
SoapDataSource.SelectParameters – Within SelectedCommand in the SOAP payload we are afforded passing in parameters. In order to provide this, use the SoapDataSource..SelectParameters.Add method to provide parameters.
The Usage Scenario
The main usage of SoapDataSource is when you wish to use custom web services for “complex data binding” or expose data with a XmlDocument object.
C# Code Example
private SoapDataSource ConstructWebServiceDataSource()
{
string rootUrl = SPContext.Current.Site.RootWeb.Url;
SoapDataSource datasource = new SoapDataSource();
datasource.SelectServiceName = "MyWebService";
datasource.SelectUrl = rootUrl + "/_vti_bin/MyServices/MyWebService.asmx";
datasource.WsdlPath = rootUrl + "/_vti_bin/MyServices/MyWebService.asmx?WSDL";
datasource.SelectAction = rootUrl + "/MyAction";
datasource.SelectPort = "MyWebServiceSoap";
datasource.SelectParameters.Add("MyParam", value);
datasource.SelectCommand = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body></soap:Body></soap:Envelope>";
return datasource;
}
Visual Basic .NET Code Example
Private Function ConstructWebServiceDataSource() As SoapDataSource
Dim rootUrl As String = SPContext.Current.Site.RootWeb.Url
Dim datasource As New SoapDataSource()
datasource.SelectServiceName = "MyWebService"
datasource.SelectUrl = rootUrl + "/_vti_bin/MyServices/MyWebService.asmx"
datasource.WsdlPath = rootUrl + "/_vti_bin/MyServices/MyWebService.asmx?WSDL"
datasource.SelectAction = rootUrl + "/MyAction"
datasource.SelectPort = "MyWebServiceSoap"
datasource.SelectParameters.Add("MyParam", value)
datasource.SelectCommand = "<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""> <soap:Body></soap:Body></soap:Envelope>"
Return datasource
End Function
The Microsoft.SharePoint.WebControls.SoapDataSource inherits from the Microsoft.SharePoint.WebControls.BaseXmlDataSource and implements the System.Web.UI.IDataSource interface. SoapDataSource’s main purpose is to build a web service sponsored abstracted datasource that data-bound controls can bind to.
In order to support arbitrary web service calls, SoapDataSource acts as a wrapper class. Taking in particular web service parameters, the output will allow you to set the DataSource property in a data-bound control to a hydrated SoapDataSource object.
In order to hydrate a new SoapDataSource object, there are some web services centric properties of the SoapDataSource object that must provided.
SoapDataSource.SelectServiceName – String representation of the friendly name of the web service.
SoapDataSource.SelectUrl – String representation of the complete URL to the web service. This can be somewhat abstracted by introducing proxy objects such as SPContext.Current.Site.Rootweb.Url to get a base location coupled with a constant deployment directory for web services.
SoapDataSource.WsdlPath – String representation of the complete URL to the web service WSDL file. The WSDL contains the model for describing the web service. This is commonly the SPDataSource.SelectUrl + “?WSDL”.
SoapDataSource.SelectPort – String representation of the exact web service SOAP protocol name
SoapDataSource.SelectAction – String representation of the action name called from the web service to execute data operations.
SoapDataSource.SelectCommand – String representation of the SOAP select command that will send XML queries and send responses via HTTP. Within the XML body element you will find the method call and parameters.
SoapDataSource.SelectParameters – Within SelectedCommand in the SOAP payload we are afforded passing in parameters. In order to provide this, use the SoapDataSource..SelectParameters.Add method to provide parameters.
The Usage Scenario
The main usage of SoapDataSource is when you wish to use custom web services for “complex data binding” or expose data with a XmlDocument object.
C# Code Example
private SoapDataSource ConstructWebServiceDataSource()
{
string rootUrl = SPContext.Current.Site.RootWeb.Url;
SoapDataSource datasource = new SoapDataSource();
datasource.SelectServiceName = "MyWebService";
datasource.SelectUrl = rootUrl + "/_vti_bin/MyServices/MyWebService.asmx";
datasource.WsdlPath = rootUrl + "/_vti_bin/MyServices/MyWebService.asmx?WSDL";
datasource.SelectAction = rootUrl + "/MyAction";
datasource.SelectPort = "MyWebServiceSoap";
datasource.SelectParameters.Add("MyParam", value);
datasource.SelectCommand = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body></soap:Body></soap:Envelope>";
return datasource;
}
Visual Basic .NET Code Example
Private Function ConstructWebServiceDataSource() As SoapDataSource
Dim rootUrl As String = SPContext.Current.Site.RootWeb.Url
Dim datasource As New SoapDataSource()
datasource.SelectServiceName = "MyWebService"
datasource.SelectUrl = rootUrl + "/_vti_bin/MyServices/MyWebService.asmx"
datasource.WsdlPath = rootUrl + "/_vti_bin/MyServices/MyWebService.asmx?WSDL"
datasource.SelectAction = rootUrl + "/MyAction"
datasource.SelectPort = "MyWebServiceSoap"
datasource.SelectParameters.Add("MyParam", value)
datasource.SelectCommand = "<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""> <soap:Body></soap:Body></soap:Envelope>"
Return datasource
End Function
- 6/3/2010
- Adam Buenz - MVP