This article shows you how to add a server-side script as a data source, how to test the data source connection, and then how to display the information returned by the server-side script by creating a Data View on your site.
Important If your site resides on a server running Windows SharePoint Services, the default settings on the server require that your server administrator first edit the Web.config file on the server before you can connect to a server-side script, as described in the section Test the data source connection. If your site resides on a server running Microsoft Office SharePoint Server 2007, you can connect to a server-side script without making any changes on the server.
In this article
What is a server-side script?
To create a Data View that displays the data provided by a server-side script, the script must retrieve data in the form of XML. You can connect to server-side scripts that are written in a variety of languages and by using a variety of methods, including ASP.NET, PHP, and AJAX. However, the script must send the resulting data in the form of XML. One common server-side script that returns XML is an RSS Feed.
If you want to add a connection to an RSS Feed that is a server-side script and not an XML file (for example, an RSS Feed that has a URL ending in .aspx or .php), the connection should be included in the Server-side Scripts category in the Data Source Library. An RSS Feed that is an XML file (for example, an RSS Feed that has a URL ending in .xml) can be added to either the Server-side Script category or the XML Files category.
To add a server-side script as a data source, you must know the URL of the script and the details of any required URL parameters.
Top of Page
Add a server-side script to the Data Source Library
- If the Data Source Library is not visible, on the Task Panes menu, click Data Source Library.
- In the Data Source Library, under Server-side Scripts, click Connect to a script or RSS Feed.
Note If the Server-side Scripts heading is collapsed, click the plus sign (+) to expand it.
- On the Source tab of the Data Source Properties dialog box, in the HTTP method list, click one of the following:
- The HTTP Get method appends any parameter names and values to the URL.
- The HTTP Post method sends any parameter names and values to the URL in the body of the request.
For this example, click HTTP Get.
- In the Select which data command to configure list, there are four options:
- The Select command retrieves information by using the server-side script. You can then display the information on your site by creating a Data View.
- The Insert, Update, and Delete commands also retrieve information by using the server-side script. However, you cannot create a Data View that displays or modifies information that is retrieved by using these commands. You can only use a Data View to display information that is retrieved by using the Select command.
For this example, click the Select command because you want to create a Data View of the data that is returned by the server-side script.
- Under Select Connection Info, in the Enter the URL to a server-side script box, type the URL for the script or RSS Feed to which you want to connect.
For this example, type http://gotdotnet.com/community/resources/rss.aspx to add an RSS Feed of developer-related articles from GotDotNet, the Microsoft .NET community Web site.
- Some server-side scripts require additional information that is passed from the browser to the server in the form of parameters. The example used here does not require parameters. If your server-side script requires parameters, do any of the following:
- To add a parameter, click Add and then, in the Parameter dialog box, type a name and default value for the parameter.
Note If the parameter is set at run time by using a Web Part Connection, select the The value of this parameter can be set via a Web Part Connection check box.
- To modify an existing parameter, click the parameter in the list, click Modify, and then, in the Parameter dialog box, modify the name or default value for the parameter.
- To remove an existing parameter, click the parameter in the list, and then click Remove.
- Click OK.
The server-side script now appears in the Data Source Library.
Top of Page
Test the data source connection
Now that you have created a data source connection that appears in the Data Source Library, you want to make sure that the connection is working properly. To test the data source connection:
- In the Data Source Library, click the data source, and then click Show Data. The Data Source Details task pane opens.
If the Data Source Details task pane displays data from the data source, the data source connection is working properly. You are ready to create a Data View of this data. Skip to the next section.
If the Data Source Details task pane does not display data from the data source, but instead the task pane either is blank or displays an error message, the data source connection is not working properly. This issue may occur if your server is running Windows SharePoint Services, the server is behind a proxy server or firewall, and the proxy server settings are not specified in the Web.config file for the virtual server.
To resolve this issue, contact your server administrator and ask him or her to perform the following procedure. The server administrator must edit the Web.config file to include the proxy server settings for the virtual server where your site resides. In a server farm environment, the server administrator must edit the Web.config file for each virtual server in every front-end Web server in the server farm.
Note Changing the default proxy server setting enables server-to-server communication but does not in any way affect inbound connections or access permissions to your server.
Configure the Web.config file on the server
To configure the Web.config file, follow these steps on the server running Windows SharePoint Services:
- Start a text editor such as Notepad.
- Locate and open the Web.config file for the virtual server where you want to allow users to create connections to XML Web service and server-side script data sources.
The Web.config folder is located in the content area of your server — for example, the default path is \Inetpub\wwwroot\wss\VirtualDirectories\80.
- Do one of the following:
- If you are running Windows SharePoint Services 3.0 Copy and paste the following lines into the Web.config file anywhere at the level directly below the <configuration> node.
<proxy autoDetect="true" />
- If you are running Microsoft Windows SharePoint Services 2.0 Copy and paste the following lines into the Web.config file anywhere at the level directly below the <configuration> node. Change <ProxyServer> to the name of your proxy server and <Port> to the port that you are using.
<proxy proxyaddress="http://<ProxyServer>:<Port>" bypassonlocal = "true"/>
- Save the Web.config file, and then exit the text editor.
- Reset Microsoft Internet Information Services (IIS) to apply your changes. Alternatively, you can reset after the next step to apply your changes to multiple virtual servers at one time. To reset IIS, open a command line window and type iisreset at the command prompt.
- Repeat steps 1 through 5 for each virtual server where you want to allow users to create connections to XML Web service and server-side script data sources.
Top of Page
Create a Data View of the server-side script
Now that you have added a server-side script to your Data Source Library, you can create a Data View that displays the results of the server-side script.
You can quickly create a Data View simply by dragging the data source onto a page. When you drag a data source onto a page, the result is a default view of the data in which the first five fields in your data source appear in each row in a basic table. If the first five fields appear with the corresponding data, the data source is configured properly.
Data Views are based on Microsoft ASP.NET 2.0 technology. To create a Data View, you must start with an ASP.NET page (.aspx file).
- On the File menu, point to New, and then click ASPX.
A new page with a FORM tag opens.
- On the Task Panes menu, click Data Source Library. In the Data Source Library task pane, locate your data source — in this example, rss.aspx on www.gotdotnet.com — and then drag it onto the page.
A Data View that contains all of the titles and URLs of all sites within the current site collection is now displayed on your page, and the Data Source Details task pane opens.
For more information about Data Views, see the article Create a Data View.
Top of Page