A
Developer’s
Guide to
Microsoft
SharePoint
Mashups
www.JackBe.com
2009
A Developer’s Guide to Mashups for Microsoft
SharePoint
Microsoft's platform for collaboration and document management, SharePoint, is widely
used in organizations for sharing information with basic workflow and is typically a
complement to existing content management systems, enterprise portals, and the like.
SharePoint supports basic information sharing but it lacks dynamic mashup capabilities.
We want to shed some light on mashing SharePoint rapidly and securely. Consider
some of the questions you (or your users) might be asking about SharePoint:
• How do I aggregate information within SharePoint?
• How do I connect SharePoint information with external information sources?
• How do I leverage SharePoint lists and web services outside of SharePoint?
• Are there Web Parts I can use to view mashed-up information in SharePoint?
• Can I view mashed-up information in Web Parts outside of SharePoint?
• Can I view mashed-up SharePoint information in others portals?
• Can I do all of this securely, using services that are protected via Microsoft
NTLM?
And any organization using Microsoft SharePoint might also wonder about mashups with
other Microsoft technologies, including ASP.Net and Silverlight. Can (and should) you
consume mashups with Microsoft Silverlight?
This guide includes a 10-step developer-centric series of implementation articles for
enterprise mashups with SharePoint (Moss 2007 and WSS 3). These articles originally
appeared on JackBe’s Mashup Developer Community at www.jackbe.com/dev.
June 2009
1
Contents
Part 1.1: Using Standard Web Parts to Publish Mashlets into Microsoft SharePoint...................... 3
An Overview .................................................................................................................... 3
SharePoint Consuming Mashlets ....................................................................................... 4
Part 1.2: SharePoint Consuming Mashups using standard XML Web Part.................................. 6
EMML and XSLT ............................................................................................................. 9
Using Mashups in Enterprise Portals................................................................................... 9
Part 1.3: SharePoint Consuming Presto Published RSS ......................................................... 10
Presto Platform Feeds..................................................................................................... 10
Presto Published RSS Feeds........................................................................................... 10
Mashup Generated RSS................................................................................................. 10
SharePoint RSS Viewer .................................................................................................. 11
Part 1.4: Using Custom Web Parts to Publish Mashlets into SharePoint ................................. 12
Introduction ................................................................................................................... 12
Presto Mashlet View Web Part........................................................................................ 12
Part 1.4.1: Creating a List Mashlets Web Part using Presto Connector for C#.......................... 17
Create MashletList Web part........................................................................................... 17
Deploying the MashletsListView Web Part........................................................................ 18
Creating a Custom Security Policy File............................................................................. 19
Add the MashletListView Web Part to a SharePoint Web Part Page ................................... 19
Rendering the MashletsListView Web Part....................................................................... 19
Part 2.1: Presto Consuming SharePoint Services ................................................................. 21
Really Simple Syndication RSS....................................................................................... 21
Part 2.2: Mashing SharePoint RSS with Presto .................................................................... 23
Publishing the SharePoint RSS Feed with Presto.............................................................. 23
Publishing the MDC Forum RSS Feed............................................................................. 24
Create and Publish a Mashup ......................................................................................... 24
Create and Publish a Mashlet ......................................................................................... 25
Part 2.3: SharePoint Web Services ..................................................................................... 26
Publishing a SharePoint Web Service on Presto ............................................................... 26
Part 2.4: Mashing SharePoint Web Services........................................................................ 27
SharePoint List Web Service........................................................................................... 27
SharePoint Search Web Service ..................................................................................... 30
2
Part 1.1: Using Standard Web Parts to Publish Mashlets into Microsoft SharePoint
An Overview
The below snapshot illustrates an example SharePoint Site homepage. This SharePoint Site, named Jackbe, will be used to illustrate various
SharePoint features. The homepage is configured to display a number of standard SharePoint Web Parts, configured to display RSS data supplied by
Presto in various forms.
There are a number of standard SharePoint Web Parts that can be used to display Presto Service Data.
• Page Viewer Web Part
The Page Viewer Web Part can be configured to display Presto Published Mashlets.
See SharePoint Consuming Mashlets at http://www.jackbe.com/enterprise-mashup/blog/sharepoint-consuming-presto-
services#sharepoint-consuming-mashlets#sharepoint-consuming-mashlets.
• RSS Viewer Web Part
The RSS Viewer Web Part can be configured to display any Presto Published RSS Service,
it is capable of displaying a variety of syndicated data feed forms including RSS, RDF and ATOM.
See Sharepoint Consuming Presto Published RSS at http://www.jackbe.com/enterprise-mashup/blog/sharepoint-consuming-presto-
published-rss.
• XML Web Part
The XML Web Part can be configured to invoke by URL any Presto Published Mashup.
The Web Part must be configured with an XSL Stylesheet to transform the returned Mashup data.
See Sharepoint Consuming Mashups at http://www.jackbe.com/enterprise-mashup/blog/sharepoint-consuming-mashups.
3
SharePoint Consuming Mashlets
Probably the quickest way of getting SharePoint to consume service data published by Presto is to configure it to display Mashlets.
The Page Viewer Web Part can be configured to display web content external to SharePoint. The Web part is configured with the URL associated with
the web content which is then displayed in a window. The window dimensions and title can be configured.
The Mashlet URL has the following general form:
http:///mashlets/uwa-view.jsp?mid=&height=
where :
• host - hostname or ip address and port number of Presto Mashup Server
• mid - is the published name of the mashlet to be displayed
• height - the height of the mashlet in pixels.
So to display a mashlet named HelloWorld.Mashlet published on the Presto Mashup Server running at 72.32.185.92:8080 the URL would be:
http://72.32.185.92:8080/mashlets/uwa-view.jsp?mid=HelloWorld.Mashlet&height=300
Mashlet name and height URL properties are mandatory.
By default the mashlet will be displayed without the standard mashlet header toolbar. The toolbar can be displayed by appending the property
toolbar=true to the URL. eg:
http://72.32.185.92:8080/mashlets/uwa-view.jsp?mid=HelloWorld.Mashlet&height=300&toolbar=true
uwa-view.jsp is a standard JSP bundled with Presto Mashup Server, on Tomcat installations you'll find it in the webapps/mashlets directory, it will display
the mashlet in a similar manner to the way mashlets/standalone.jsp does but without the header and framing, it expects to display a mashlet rendered in
an iframe.
Presto.ServiceMashlet
Presto.ServiceMashlets are the particular type of mashlet published by Presto MashletMaker when exposing a Presto published Service with a web UI.
This mashlet type is designed to allow mashlets to be configured with specific, primitive, input parameter data, which is required to invoke the
underlying Presto Published Service.
Primitive data types supported by Presto.ServiceMashlet are numbers, strings and dates, generally anything that can be represented in the form of a
character string. Complex data types, where the parameter is composed of multiple properties are not supported by Presto.ServiceMashlet.
If a Presto.ServiceMashlet type is being configured and if that mashlet supports input parameters then these input parameters can also be included in
the mashlet URL. For example, a Stock Quote Mashlet, called MyQuotes, might be configured to accept a single string parameter, named "Symbol"
which is a comma separated list of Stock symbols, so we might have a URL such as:
http://72.32.185.92:8080/mashlets/uwa-view.jsp?mid=MyQuotes&height=300&Symbol=ORCL,JAVA,IBM,MSFT
4
Mashlet Dimensions
The Mashlet dimensions are controlled by the Page Viewer Web Part Appearance settings, where the pixel width and height can be set. Note also that
the height of the mashlet must be explicitly passed to the mashlet as part of the mashlet URL. The height specified in the Web Part Appearance
property should match the value specified in the mashlet URL. If the 2 height values do not match then a vertical scrollbar may appear or whitespace
may appear beneath the mashlet.
Unlike the height property, the width of the mashlet is computed automatically and does not need to be specified in either the Web Part Appearance
settings or in the URL. If no width setting is specified then the Web Part and mashlet will just take up whatever horizontal space is available. If a width
dimenension is specified in the Web Part Appearance settings then the Web Part width will adjust to that width and the Mashlet will resize
automatically to take up that width.
Using Mashlets in Enterprise Portals
All the Mashlet artifacts discussed in these SharePoint articles are reusable in your Enterprise Portal (JSR-168 and WSRP compliant) using
our Presto Connector for Enterprise Portal. The Presto Documentation also includes a useful discussion of the pros and cons of using Mashlets
or Presto Mashups as base for Enterprise Portlets.
5
Part 1.2: SharePoint Consuming Mashups using standard XML Web Part
With a fairly basic knowledge of XSL, XPath and XSL Stylesheets, the SharePoint XML Web Part can provide a front-end for Presto Mashups. The
XML Web part can actually be used to invoke any REST-like, XML based, non-SOAP Web Service, where the invocation request is encapsulated in a
URI and the response is received as an XML document.
So prerequisites for the Presto Service are:
• Any input parameters required by the Service are primitive and can be included as part of the Service URI.
• Inclusion of input parameters in the URI does not represent a security threat.
• Any authorization credentials required by the Service can be included in the Service URI.
The screenshot below shows an example of a simple Presto Mashup Service being configured for display in an XML Web Part. The Mashup is one of
the out-of-the-box RSS Feeds provided by Presto, it returns a summary of Top Rated Presto Published Services. The screenshot shows the XML
Web Part in Edit mode.
The Service URI is of the form:
http://host:port/presto/edge/api/rest/PrestoServicesFeed/1.0/getFeed?presto_user=username&presto_password=password&feed=TopRatedServices&count=10
6
Here is a sample of the returned XML document:
PrestoServices
http://localhost:8080/presto/feeds.jsp?format=rss&activity=register&item=services
List of services registered in Presto
en-us
2009-01-19T17:04:03.368-06:00
60
hourly
salesforce
salesforce
Salesforce service
SalesForce
SalesForce
WSDL
salesforce
WSDL, Salesforce
1
4
salesforce
Service
16
ACTIVE
TechCrunchRSS
TechCrunchRSS
TechCrunch
NONE
NONE
RSS
TechCrunchRSS
RSS, Startups, Analysis, News, Technology
1
4
TechCrunchRSS
Service
22
ACTIVE
....
....
....
7
We could use a standard SharePoint RSS Web Part to view this Service data. The RSS Web Part provides an equivalent mechanism for performing
XSL transformation of RSS Feed data.
However, we'll use XML Web Part in this case to illustrate how the XSLT stylesheet transformation can be applied.
By placing the Web Part in Edit mode and selecting the XSL Editor we are able to cut and paste an XSLT Stylesheet to transform the RSS Feed
document and prepare a HTML table summary of the feed items:
Service
Description
Type
Provider
State
Rating
Ratings
8
Below we have the resulting XML Web Part rendering.
EMML and XSLT
An experimental feature of EMML also allows XSLT Stylesheet transformations to be applied to EMML Mashups directly, either by referencing the
stylesheet inline or passing a reference in as an input parameter.
An EMML XSLT example can be found in the Presto Mashup Samples, under EMML Mashup Samples -> EMML Features -> XSLT, where an XSLT
stylesheet is included inline, converting a Mashup response document into a SVG barchart.
Using Mashups in Enterprise Portals
All Mashlet and Mashup artifacts discussed in these SharePoint articles are reusable in your Enterprise Portal (JSR-168 and WSRP compliant) using
our Presto Connector for Enterprise Portal (found at
http://www.jackbe.com/prestodocs/v2.6.1/prestolibrary/wwhelp/wwhimpl/api.htm?href=PrestoLibrary.1.102.html#34093). The Presto Documentation
also includes a useful discussion of the pros and cons of using Mashlets or Presto Mashups as base for Enterprise Portlets at
http://www.jackbe.com/prestodocs/v2.6.1/prestolibrary/wwhelp/wwhimpl/api.htm?href=PrestoLibrary.1.102.html#34093.
9
Part 1.3: SharePoint Consuming Presto Published RSS
There are a number of RSS Feed categories published by Presto Enterprise Mashup Server:
1. Presto Platform Feeds:
A number of standard platform feeds are published by Presto providing summary status of Presto published services, such as recently
published services, top rated services etc.
2. Presto Published RSS Feeds:
Syndication data formats RSS and ATOM are supported by Presto.
Presto also supports a number of authentication protocols such as NTLM, Basic Auth and SSL.
By default Presto supports the transformation of Published Syndicated Services into a single unified format.
3. Presto Mashup Generated RSS:
A Presto Mashups can be designed to output its data in the form of an RSS Feed.
Presto Platform Feeds
The Presto Platform Feeds are intended to be used to monitor various service related activity such as
• top rated presto services
• recently published services
These platform feeds require username/password authentication to be included in the feed URL.
Presto Published RSS Feeds
The User documentation states the following:
Currently, you can only publish syndication services that use one of the two syndication standards (RSS or Atom) as a Presto RSS serivce. Services
that use the alternate format must be published as REST services.
The format that Presto accepts for a syndication service is defined in Mashup Server configuration. By default, Presto is configured to publish and
normalize syndication services using the RSS standard.
Any Syndicated Service published in Presto can be accessed via a Presto URL. If the Syndicated Service is authenticated then Presto can handle the
authentication. Details in the user documentation on how to publish here:
http://www.jackbe.com/prestodocs/v2.6.1/prestolibrary/wwhelp/wwhimpl/js/html/wwhelp.htm?href=PrestoLibrary.1.55.html
Mashup Generated RSS
Presto Mashups can be designed to output data in the form of an RSS Feed.
• A single RSS Feed might be filtered.
• One or more RSS feeds might be combined to generate a merged RSS Feed.
• A Feed might be decorated with data from an non-RSS service data input, but the output retaining the RSS form.
• One or more non-RSS services might be mashed and the FormatAsRSS Wires Action/EMML Command used to reform the output in the
form of an RSS Feed.
The FormatAsRSS Wires Action is not yet released as part of the standard product and must be downloaded and manually installed. Instructions are
provided here :
Create RSS Feed From Any Service Output at http://www.jackbe.com/enterprise-mashup/blog/create-rss-feed-any-service-output.
10
SharePoint RSS Viewer
The standard SharePoint RSS Viewer is capable of displaying a variety of Syndication data formats including:
• RSS
• ATOM & ATOM2
• RDF
Configuring the RSS Viewer Web Part simply requireds the Presto published feed URL to be entered in the RSS Properties Section of the Edit panel,
see snapshot. The Web Part also allows the following to be configured:
• the number of displayed items can be controlled.
• Whether to show title and description.
The Miscellaneous property section provides options to enable a timeout on the caching of the feed data.
Data View Properties provides the option to edit and customize the XSL Stylesheet used to transform the feed into readable hypertext, for example
adding the display of some extended set of parameter data.
11
Part 1.4: Using Custom Web Parts to Publish Mashlets into SharePoint
Introduction
This section will illustrate how SharePoint custom Web Parts can be used to access Presto Mashups. The section will detail the process of writing and deploying the Web Parts to
a SharePoint Site.
The Presto User Documentation Section Using Presto Connect for C# provides a brief introduction to the Presto Connector API for C# which will be used in this section.
(http://www.jackbe.com/prestodocs/v2.6.1/prestolibrary/wwhelp/wwhimpl/api.htm?href=PrestoLibrary.1.280.html)
All of the sample Web Parts have been developed using standard ASP.NET 2.0 Web Part framework, rather than the SharePoint Web Part infrastructure, which is recommended
practice.
The figure below provides an overview of the Presto Web Part architectural design. On the left we have a browser displaying a SharePoint site web page containing a pair of
Presto web parts. In the center we have the SharePoint server and on the right we have the Presto Mashup Server.
2 Web Parts are shown:
• The upper Web part represents an example of a simple Mashlet View Web Part, which connects directly back to the Presto Mashup Server to retrieve a Mashlet,
the Mashlet is then displayed within the Web part frame.
• The lower Web Part makes use of ASP.NET Server Controls to build a UI and connects back to Presto mashup Server using the Presto Connector for C#.
Prerequisites
The sample web parts were developed using Visual Studio 2008 and the Microsoft Office SharePoint Server SDK 1.4, which includes Windows SharePoint Services 3.0 SDK.
The Sharepoint Server can be found at http://msdn.microsoft.com/en-us/library/ms550992.aspx, and the Sharepoint Services are at
http://www.microsoft.com/downloads/details.aspx?FamilyId=D51730B5-48FC-4CA2-B454-8DC2CAF93951&displaylang=en)
Presto Mashlet View Web Part
The intention with this first Presto Web Part is to provide a more user friendly version of the Page Viewer Web part previously discussed. It can be considered to be the most
simple of Web Parts and is the easiest to install and use.
The screenshot below shows the installed Web Part in Edit Mode. Having added the Web part to a Web Part page, the user is required to specify the following Mashlet
properties:
1. hostname
2. port number
3. mashlet name
The Mashlet being rendered is a Sample.BubbleChart Mashlet, which is the subject of a blog entry, BubbleChart Sample Mashlet, where it is available for download, it should
be available as a standard sample mashlet in the next Presto release.
12
Creating the Mashlet View Web Part
• With the SharePoint Server SDK installed you should be able to create a new web part project by selecting the C# SharePoint Web Part Template, name the
Project Jackbe.Samples.
• Delete the default WebPart, WebPart1, and add a new WebPart named MashletView. Which should generate the following template class:
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace Jackbe.Sample
{
[Guid("9ea88355-c62b-4ddf-8775-e18c2a8b5304")]
public class MashletView : System.Web.UI.WebControls.WebParts.WebPart
{
public MashletView()
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
}
}
• The template class includes the Microsoft.SharePoint namespaces, these can be removed as we will be using the standard ASP.NET 2.0 Web Part classes.
• We'll define a number of Web Part Properties which we'll be able to edit in order to configure the Web Part:
• MashletName, the name which identifies the Mashlet
• Hostname, the Mashup Server IP Address
• Port number, Mashup Server Port number
• Show/Hide Mashlet Toolbar, to reduce screen clutter we'll hide the Mashlet Toolbar by default
13
• For each property we annotate it so that it is:
• WebBrowsable, viewable when Web Part is in Edit mode
• WebDisplayName, the displayed name of the property
• WebDescription, tooltip description for property
• Personalizable, we set the Personalizable scope to shared so that all page users share the same web part properties.
private string _MashletName;
private string _Hostname;
private string _Port;
private bool _Toolbar = false;
[WebBrowsable(true)]
[WebDisplayName("Mashlet Name")]
[WebDescription("Name of Presto Mashlet")]
[Personalizable(PersonalizationScope.Shared)]
public String MashletName
{
get { return _MashletName; }
set { _MashletName = value; }
}
[WebBrowsable(true)]
[WebDisplayName("Hostname")]
[WebDescription("Presto Hostname")]
[Personalizable(PersonalizationScope.Shared)]
public String Hostname
{
get { return _Hostname; }
set { _Hostname = value; }
}
[WebBrowsable(true)]
[WebDisplayName("Port")]
[WebDescription("Presto mashlet host Port number")]
[Personalizable(PersonalizationScope.Shared)]
public string Port
{
get { return _Port; }
set { _Port = value; }
}
[WebBrowsable(true)]
[WebDisplayName("Show Mashlet Toolbar")]
[WebDescription("Show/hide Mashlet header toolbar")]
[Personalizable(PersonalizationScope.User)]
public Boolean Toolbar
{
get { return _Toolbar; }
set { _Toolbar = value; }
}
• Remove the CreateChildControls method, which we will not use in this case, and add the following Render method. The method checks to see that values have been
assigned to each property before constructing an iframe element:
• Iframe src attribute points to uwa-view.jsp, a utility JSP which expects to render a mashlet inside an iframe. We explicitly pass in the configured height of
the Web Part together with the name of the mashlet (mid), and the toolbar property.
• Iframe frameborder is hidden to remove clutter.
• Iframe scrollers are disabled, to prevent the scrollbars appearing, which is the case with the default Page Viewer Web Part.
• Explicitly set the height of the Iframe.
protected override void Render(HtmlTextWriter writer)
{
if (String.IsNullOrEmpty(MashletName))
{
this.renderError(writer, "MashletName not specified");
}
else if (String.IsNullOrEmpty(Hostname))
{
this.renderError(writer, "Mashlet Hostname not specified");
}
else if (String.IsNullOrEmpty(Port.ToString()))
{
this.renderError(writer, "Mashlet Port not specified");
}
else
{
string showToolbar = Toolbar.ToString();
string height = Height.Value.ToString();
string iframeTag = "";
writer.Write(iframeTag, new String[] { Hostname, Port, MashletName, height, showToolbar });
}
}
private void renderError(HtmlTextWriter writer, string message)
{
writer.Write("{0}", message);
}
14
Finally, a few minor presentation details, we'll override a couple of the standard IWebPart methods to further customize the Web Part:
1. Display a Presto Icon
2. Link to the mashlet in a standalone web page from the Web Part Title.
3. Set a default height.
public override string TitleUrl
{
get
{
return "http://" + Hostname + ":" + Port + "/mashlets/standalone.jsp?mashlet=" + MashletName;
}
set { return; }
}
public override string TitleIconImageUrl
{
get
{
if (String.IsNullOrEmpty(Hostname) || String.IsNullOrEmpty(Port)){
return base.TitleIconImageUrl;
} else {
return "http://" + Hostname + ":" + Port + "/presto/images/presto.ico";
}
}
set { return; }
}
public override System.Web.UI.WebControls.Unit Height
{
get{ return base.Height.IsEmpty ? 400 : base.Height; }
set{ base.Height = value; }
}
Deploying the Mashlet View Web Part
Having built the Web Part Assembly we will deploy it to the SharePoint bin directory, which is the recommended method of deployment.
Assuming a default Visual Studio 2008 installation, the dll should be:
C:\Documents and Settings\username\My Documents\Visual Studio 2008\Jackbe.Sample\MashletView\bin\Debug.
Assuming a default SharePoint installation, the destination bin should be:
C:\Inetpub\wwwroot\wss\VirtualDirectories\port number\bin
Finally, in order for SharePoint to recognise the new Web part as being safe to use, we must add a Safe Control entry in web.config for the new Web Part.
The web.config will be found in the bin parent directory:
C:\Inetpub\wwwroot\wss\VirtualDirectories\port number\web.config
Open the file with a text editor such as Notepad, locate the SafeControls section and add the following child element entry:
Now we are ready to add the new Web Part to the SharePoint Web Part gallery.
1. From your SharePoint Site homepage, select Site Actions->Site Settings
2. In Site Settings, select Web Parts from the Galleries column, which will display the Web Part Gallery.
3. Select *New to add a new Web Part, this will display a list of all available New Web Parts.
4. Select the checkbox for the Jackbe.Sample.MashletView and click the Populate Gallery button, this will return you to the Web Part Gallery where you should
see the new Web part listed as MashletView.webPart!NEW.
1. The mashlet can now be added to any Web Part page. We could change the mashlet settings so that it appears in a new Grouping, by default it will appear under
Miscellaneous Web Parts.
Rendering the Mashlet View Web Part
1. Navigate to the Web Part page where you want to add the MashletView Web Part, select Site Actions-> Edit Page.
2. Click Add a Web Part in the zone you wish to add the Web Part, this should pop up the Add Web Parts dialog where you should find the new MashletView Web
Part listed in the Miscellaneous section. Select the checkbox and click Add, this should add the web Part to the current page.
3. Select Web Part Edit-> Modify Shared Web Part to configure the mashlet properties.
15
The screenshot below shows the final rendered Mashlet.
Sample Code
A Visual Studio 2008 Project which includes the 2 sample Web Part implementations, Jackbe.Sample.zip, can be found at http://www.jackbe.com/enterprise-
mashup/sites/default/files/Jackbe.Sample.zip. In order to open the project file Visual Studio 2008 you should have Microsoft Office SharePoint Server SDK 1.4 installed, or you
can always just look at the source code or copy it into your own development environment.
16
Part 1.4.1: Creating a List Mashlets Web Part using Presto Connector for C#
Whereas the MashletView Web Part, described in the previous article, provides a web part viewer in which to render a Mashlet, this second Web Part will make use of the Presto
Connector for C# and ASP.NET UI Controls to access the Mashup Server and render the Web Part UI. Presto Connector for C# can be found at
http://www.jackbe.com/prestodocs/v2.6.1/prestolibrary/wwhelp/wwhimpl/api.htm?href=PrestoLibrary.1.280.html.
We will keep things as simple as possible in order to focus on the process of building and deploying the Web Part.
We will create Web Part which uses Presto Connector for C# (PC4C#) to retrieve a list of available Mashlets from Presto Mashup Server and display the list using
a System.data.GridView UI Control.
Create MashletList Web part
1. We can either create a new project or add this new Web Part to the Jackbe.Samples Assembly, created in the previous article for the MashletView Web Part. We'll
assume the same project is used.
2. Download and install the PC4C#, instructions can be found under Installing the Presto Connect for C# Library located here,
http://www.jackbe.com/prestodocs/v2.6.1/prestolibrary/wwhelp/wwhimpl/js/html/wwhelp.htm.
3. The Web Part will be dependent on 2 Assemblies bundled with the PC4C#:
• Jackbe.PrestoConnect.Net.dll
• NetServ.Net.Json.dll
4. Add References to these 2 assemblies.
5. Create a new Web Part named MashletsList and reference the PC4C# assemblies:
using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using JackBe.Presto.Connect.Net;
using NetServ.Net.Json;
namespace Jackbe.Sample
{
[Guid("5d77828a-4a62-428e-871e-93e740365d36")]
public class MashletsListView : System.Web.UI.WebControls.WebParts.WebPart
{
public MashletsListView()
{
}
protected override void CreateChildControls()
{
base.CreateChildControls();
}
}
}
6. The following additional namespace statements will be required:
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;
7. As with the previous Mashlet, we will define Web Part properties so we can configure which Presto Mashup Server the Web Part will connect to. We also define
properties to hold user credentials which may be required to access Presto Services.
private string _Hostname;
private string _Port;
private string _Username;
private string _Password;
[WebBrowsable(true)]
[WebDisplayName("Hostname")]
[WebDescription("Presto Hostname")]
[Personalizable(PersonalizationScope.Shared)]
public String Hostname
{
get { return _Hostname; }
set { _Hostname = value; }
}
[WebBrowsable(true)]
[WebDisplayName("Port")]
[WebDescription("Presto Port number")]
[Personalizable(PersonalizationScope.Shared)]
public string Port
{
get { return _Port; }
set { _Port = value; }
}
[WebBrowsable(true)]
[WebDisplayName("User Name")]
[WebDescription("Presto User Name")]
[Personalizable(PersonalizationScope.Shared)]
public string Username
{
get { return _Username; }
set { _Username = value; }
}
[WebBrowsable(true)]
[WebDisplayName("Password")]
[WebDescription("Presto User Password")]
[Personalizable(PersonalizationScope.Shared)]
[PasswordPropertyText(true)]
public string Password
{
get { return _Password; }
set { _Password = value; }
}
17
8. The following GetMashletsDataSet method will connect to the Presto Mashlet Server and retrieve a summary list of all available Mashlets. This Mashlet summary
data is then used to populate a DataSet object which is returned by the method.
private DataSet GetMashletsDataSet()
{
DataSet dataSet = new DataSet();
DataTable table = new DataTable();
table.Columns.Add("Name");
table.Columns.Add("Title");
table.Columns.Add("Description");
table.Columns.Add("Type");
table.Columns.Add("Created");
table.Columns.Add("Owner");
Connection connection = this.GetConnection();
JsonObject response = this.GetMashlets(connection);
JsonObject mashletMap = (JsonObject)response["map"];
foreach (KeyValuePair pair in mashletMap)
{
string name = pair.Key;
JsonObject config = (JsonObject)mashletMap[name];
string title = config["title"].ToString();
string description = config["description"].ToString();
string type = config["type"].ToString();
string created = config["created"].ToString();
string owner = config["createdBy"].ToString();
table.Rows.Add(new Object[] { name, title, description, type, created, owner });
}
dataSet.Tables.Add(table);
connection.Logout();
return dataSet;
}
private Connection GetConnection()
{
Connection connection = new Connection();
connection.HostName = Hostname;
connection.PortNo = Int32.Parse(Port);
connection.Login(Username, Password);
return connection;
}
private JsonObject GetMashlets(Connection connection)
{
JumpResponse response = connection.Invoke("MashletHub", "getMashlets");
JsonObject json = response.ResponseBody.Json;
return json;
}
9. The final part of the implementation is to add the CreateChildControls method, to retreive the DataSet of Mashlet details and bind it to a GridView UI Control.
private GridView MashletsView;
private DataSet MashletsDataSet;
protected override void CreateChildControls()
{
base.CreateChildControls();
if (String.IsNullOrEmpty(Hostname))
{
Label label = new Label();
label.Text = "Web Part not configured";
Controls.Add(label);
return;
}
MashletsView = new GridView();
MashletsView.AllowSorting = true;
MashletsView.AllowPaging = true;
MashletsView.PageSize = 10;
MashletsView.EnableSortingAndPagingCallbacks = true;
MashletsView.Sorting += new GridViewSortEventHandler(MashletsView_Sorting);
MashletsView.PageIndexChanging += new GridViewPageEventHandler(MashletsView_PageIndexChanging);
MashletsDataSet = GetMashletsDataSet();
MashletsView.DataSource = MashletsDataSet;
Controls.Add(MashletsView);
MashletsView.DataBind();
}
protected void MashletsView_Sorting(object sender, GridViewSortEventArgs e)
{
MashletsDataSet.Tables[0].DefaultView.Sort = e.SortExpression;
MashletsView.DataBind();
}
protected void MashletsView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
MashletsView.PageIndex = e.NewPageIndex;
}
Deploying the MashletsListView Web Part
We follow a similar deployment procedure to Mashlet View Web part, except in this case we also have a few dependent Assemblies to deploy and we need to configure the
SharePoint server to allow the Web Part to access Sharepoint Server Web Resources, see Microsoft Windows SharePoint Services and Code Access Security for more details,
located at, http://msdn.microsoft.com/en-us/library/ms916855.aspx.
The 3 Assemblies to deploy are:
1. Jackbe.Sample.dll, our Web Part implementation(s)
2. Jackbe.PrestoConnect.Net.dll, the Presto Connection for C# assembly
3. NetServ.Net.Json.dll, a lightweight library for handling JSON notation written in C#, located at, http://code.google.com/p/netserv-net-json/.
The Assemblies should be copied to:
C:\Inetpub\wwwroot\wss\VirtualDirectories\port number\bin
18
Add a Safe Control entry in web.config for the new Web Part:
Finally we need to configure the SharePoint Server to allow the Web Part to connect to the Presto Mashup Server. We have 2 options, one simple one not so simple:
• The simple option is to update web.config so that the default trust level is set to Full, so that all Web Parts have full access to SharePoint resources. This is just a
matter of locating the trust element in web.config and replacing the default trust level,WSS_Minimal setting to Full:
• The not so simple option is to set up a custom security policy for your SharePoint Site, as documented here, Setting the Trust Level for a Virtual Server, and
outlined below.
Creating a Custom Security Policy File
Rather than applying a Full trust level we will create a custom security policy which extends the standard SharePoint WSS_Minimal trust level.
Navigate to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\config\, the default location for SharePoint security policy files, and create a copy of
of WSS_MinimalTrust.config, name it something like Presto_WSS_MinimalTrust.config
Open Presto_WSS_MinimalTrust.config and create a copy of the PermissionSet named SPRestricted, rename the copy as Presto and append a new IPermissionSet element which
defines a WebPermission setting:
Insert, as the first child, a new CodeGroup element which uses a UrlMembershipCondition to reference all the Jackbe.*.dlls in bin:
Having saved the updated config file, we must now update web.config to reference this file. Locate the SecurityPolicy element and add a the following new trustLevel child element:
Finally, we must reset the server so that it picks up this config change. Open a console window and enter the command iisreset.
Now we are ready to add the new Web Part to the SharePoint Web Part gallery.
Add the MashletListView Web Part to a SharePoint Web Part Page
1. From your SharePoint Site homepage, select Site Actions->Site Settings
2. In Site Settings, select Web Parts from the Galleries column, which will display the Web Part Gallery.
3. Select *New to add a new Web Part, this will display a list of all available New Web Parts.
4. Select the checkbox for the Jackbe.Sample.MashletsListView and click the Populate Gallery button, this will return you to theWeb Part Gallery where you
should see the new Web part listed as MashletsListView.webPart!NEW.
5. The mashlet can now be added to any Web Part page. We could change the mashlet settings so that it appears in a new Grouping, by default it will appear under
Miscellaneous Web Parts.
Rendering the MashletsListView Web Part
1. Navigate to the Web Part page where you want to add the MashletsListView Web Part, select Site Actions-> Edit Page.
2. Click Add a Web Part in the zone you wish to add the Web Part, this should pop up the Add Web Parts dialog where you should find the new MashletsListView
Web Part listed in the Miscellaneous section. Select the checkbox and click Add, this should add the web Part to the current page.
3. Select Web Part Edit-> Modify Shared Web Part to configure the mashlet properties. The screenshot below shows the unconfigured Web Part in Edit Mode.
19
4. Having configured the hostname, port, username and password properties, apply and save these setting. The screenshot below shows the final rendered Mashlet.
20
Part 2.1: Presto Consuming SharePoint Services
This article will focus on how SharePoint generated RSS can be consumed by Presto, other articles will look at SharePoint Web Service consumption and how SharePoint
Services can be mashed using Presto.
Here are links to the other articles:
• Mashing Sharepoint RSS Feeds with Presto Wires (http://www.jackbe.com/enterprise-mashup/blog/mashing-sharepoint-rss-presto)
• Sharepoint Web Services (http://www.jackbe.com/enterprise-mashup/blog/sharepoint-web-services)
• Publishing a Sharepoint Web Service on Presto
• Mashing Sharepoint Web Services (http://www.jackbe.com/enterprise-mashup/blog/mashing-sharepoint-web-services)
Really Simple Syndication RSS
SharePoint 2007 has extensive support for publishing data using RSS, enabling users to subscribe to SharePoint data services such as Blogs, Task Lists, Discussions,
Document Lists, Link Lists and Search Results.
The RSS Feeds can be consumed internally within the SharePoint Environment, they can also be consumed externally, with access protected by NTLM Authentication by default.
Presto Enterprise Mashup Server version 2.6.1 or later is able to consume NTLM protected Services.
Enabling SharePoint RSS
The SharePoint Web Application Settings "RSS Settings" property must be enabled to allow users to subscribe to SharePoint List views in syndicated format. This option is
enabled by default. The option can be checked via Central Administration, Web Application Management section, Web Application Settings.
Almost any list-based data service provided by SharePoint can be published in RSS form. The following are a selection of the SharePoint data services which can be RSS
enabled:
1. Blogs
SharePoint Site users can create and edit blog posts.
Blog entries can be posted to both site and personal blogs.
Access to blog posts can be controlled by setting user permissions.
Access to blogs is restricted to authorized users.
Users are able to subscribe to a blog RSS Feed.
The Recent Blog Posts Data Form Web Part is able to display in summary form,
recent blog posts for a given user to which the viewing users has access.
Can this Web part be published as RSS?
2. Discussion Lists
SharePoint Discussion lists are a useful source of information which can be published in RSS form and which Presto can consume.
In RSS Form a SharePoint Discussion list is comprised of a set of discussion topics,
with title and description and a NTLM Authenticated URL link back to the actual SharePoint Discussion page.
A Discussion List might be mashed up with discussion topics gathered from sources external to SharePoint.
Merged and filtered the discussion could then be consumed either by SharePoint or some external non-SharePoint user environment in the form of an RSS Feed
or Mashlet.
3. Calendars
4. Task Lists
5. Announcement Lists
6. Issue Tracking Lists
7. Link Lists
8. Key Performance Indicators (KPI) List
A KPI Web Part can be configured to view a KPI List.
Key Performance Indicator lists a set of user defined indicators including target goal,
current value and target status information.
9. Filter Web Part
Filter Web Part enables the user to connect to multiple data sources and to dynamically
collect and filter data.
10. Search Results
RSS Feed URL General form is :
http://host/Site/_layouts/listfeed.aspx?List=Guid
21
SharePoint Search Results
SharePoint Search Results can be made available as an RSS feed. This may be a suitable for the case where the user wishes to periodically check search results for a give set
of fixed search criteria.
SharePoint provides various Web Parts through which the user is able to customize the Search criteria and Search Results.
Customization of Search Criteria enable us to control details of the search query and the scope of the search. Customization of the Search Results enable us to control the
content and structure of the Search Result which, in turn, will alter the content of the Search Result RSS feed.
Customization may take the form of:
• search scope and query
• result paging
• handling of duplicate result entries
• grouping and collapsing of search results
The Search Actions Web Part must be configured to Display RSS, which can be performed by:
1. Selecting Edit Page in the Site Actions menu.
2. Edit the Search Actions Link Web part.
3. Select Modify Shared Web Part.
4. Ensure the Display RSS Link checkbox is selected in the Search Results Action Links list.
See Overview of SharePoint 2007 Search capabilities at http://technet.microsoft.com/en-us/library/cc580567.aspx.
Having retrieved a set fo search results, displayed in a search result list view, the search results can be viewed in RSS format by selecting "View RSS Feed" from the List Actions
menus. SharePoint will redirect to a URL for the Search Results in RSS form. The URL will include an encoded reference to Search Result List from which the RSS Feed is
derived.
The URL includes a single parameter which identifies the GUID of the List from which the Feed is derived.
As with all RSS feeds exposed by SharePoint access to the feed will be controlled by NTLM Authentication.
Consuming SharePoint RSS Feeds
Having identified the SharePoint RSS Feed URL, we're able to publish the feed as a Presto Syndicated Service.
The following information is required to register a SharePoint RSS Feed as a Presto Syndication Service:
1. RSS Feed URL
2. NTLM credentials, Username, password and domain.
Optionally:
• Choose an existing or create a new Presto Application to which the Serivce will be assigned.
• Select a Service Provider to be associated with the service.
• Choose one or more service Tags, for example you may wish to tag services with the name "SharePoint" and all services from a given site with the SharePoint
Site name.
Password credentials are stored in encrypted form.
The full procedure for publishing a Syndicated Service to Presto is detailed at Service Explorer Publishing a Syndication (RSS/ATOM) Service
(http://www.jackbe.com/prestodocs/v2.6.1/prestolibrary/wwhelp/wwhimpl/js/html/wwhelp.htm?context=prestolibrary&topic=services)
Having published and activated the service, the service is now mashable.
• We can expose this service as a mashlet using MashletMaker.
• We can combine the service with others to create a Mashup using Wires or Mashup Studio.
22
Part 2.2: Mashing SharePoint RSS with Presto
This is the seventh in a many-part series about Mashups and Microsoft SharePoint. You can read about the entire series at http://www.jackbe.com/enterprise-
mashup/blog/mashing-sharepoint-introduction.
In this article we'll publish a pair of RSS Feeds with Presto, use Wires to combine and filter the Feeds to create a Mashup, and finally, expose the Mashup as a Mashlet. One of
the feeds will be provided by SharePoint and the other will be from a non-SharePoint source, so we will be demonstrating how Presto can be used to mash SharePoint data with
external data source.
So we have a 4 stage procedure:
1. Publish the SharePoint RSS Feed on Presto using Service Explorer.
2. Publish the external RSS Feed on Presto using Service Explorer.
3. Create and publish a Mashup using Wires.
4. Create and publish a Mashlet of the Mashup using MashletMaker.
We will take a SharePoint Site Team Discussion List, exposed as an RSS Feed, and merge it with the an RSS feed of the MDC Forum postings over the last 30 days. We will
also filter the merged feed for items that carry a key word.
Publishing the SharePoint RSS Feed with Presto
The screenshot below shows the example SharePoint Team Discussion List which we will publish in Presto as an RSS Feed. The List can be viewed in the form of an RSS Feed
by selecting Actions -> View Feed. The RSS Feed URL identifies the GUID associated with this SharePoint List.
Before publishing the SharePoint RSS Feed to Presto we need to gather the following information, assuming we have a SharePoint Site named Jackbe :
1. A name to uniquely identify the published Presto Service, eg. SpJackbeDiscussion, signifying Sharepoint Service, Jackbe Site,Discussion List.
2. The URL for the RSS Feed, eg. http://www.mycompany.com/sites/Jackbe/_layouts/listfeed.aspx?List={GUID}, where GUID is the Id asscoaited with the RSS Feed.
3. NT Lan Manager (NTLM) Username, password and domain.
23
Using Presto ServiceExplorer, we launch the RSS/ATOM publishing wizard and enter our details, select NTLM authentication and enter our user credentials. The screenshot
below shows an example of the Service details entered in the Service Explorer Publishing Wizard:
Presto will access the service, read and validate the feed and prepare the Service as a Presto Published Service. If successful, the wizard will stop to allow us to configure role
based access to the service as a whole and/or to individual getFeed operation.
Having published the service, by default the service will be activated and ready to be invoked, we are now ready to use the service as a Mashable in Wires.
Publishing the MDC Forum RSS Feed
Unlike the SharePoint Feed, the MDC Forum Feed does not require authentication. The screenshot below shows the Feed being published using the Service Explorer publishing
wizard. We name the service MDCForum30DayPosts.
Having successfully published the second feed we are ready to mash the 2 feeds using wires.
Create and Publish a Mashup
• Launch Wires and locate the 2 newly published RSS Services in the Service pallette.
• Drag the 2 services out onto the canvas, both services only have the one operation associated with them and these will be selected automatically.
• We can test the services by invoking them and viewing the returned service data in the preview panel.
• Drag out a Merge Action Block onto the canvas and merge the 2 feeds.
• We can test that the merged output contains data from both feed sources.
• Drag out a filter Action Block, we can now set up the Filter Action to filter out feed items that do not contain a particular keyword in either the item title or
description.
• To complete the Mashup we connect the Service block to the Mashup Output block.
• We can now save the Mashup, assigning a unique name to it, tagging and providing a description.
• Having saved the Mashup we can publish it so that it becomes externally accessible.
24
The screenshot below shows the completed mashup.
Having published the Mashup we can now expose the Mashup as a Mashlet. Once the mashup is published, Wires provides us with a shortcut via a toolbar button to create a
Mashlet from the current Mashup.
See Creating Mashups for further details explaining how to use Wires to create Mashups, located here,
http://www.jackbe.com/prestodocs/v2.6.1/prestolibrary/wwhelp/wwhimpl/api.htm?href=PrestoLibrary.1.114.html.
Create and Publish a Mashlet
We will create a Mashlet which exposes the Mashup as a Mashlet so that the information can be made available to users outside the SharePoint environment.
• Launch MashletMaker, either from within Wires or via the Presto Home page.
• Select the RSS Mashup previously published.
• Select the single operation exposed by the mashup, runMashup.
• MashletMaker will now prompt us to select the type of View we wish to use, select RSS.
• Mashlet Maker will now render the mashlet as shown in the screenshot below.
• We can now choose to publish the mashlet or further alter it by modifying mashlet appearance or role based security setting.
25
Part 2.3: SharePoint Web Services
This is the eigth in a many-part series about Mashups and Microsoft SharePoint. You can read about the entire series at http://www.jackbe.com/enterprise-
mashup/blog/mashing-sharepoint-introduction.
Presto version 2.6.1 or later is capable of consuming SharePoint Web Services, earlier versions of Presto did not support the NTLM Authentication.
SharePoint Web Service Endpoints have the general form:
http://site address/_vti_bin/service name.asmx
The following SharePoint Web Services are considered to be of particular interest as Presto Published Services:
Sites /_vti_bin/sites.asmx Provides methods for returning information about the site templates for a site collection.
Lists /_vti_bin/Lists.asmx Provides methods for working with lists and list data.
Views /_vti_bin/Views.asmx Provides methods for working with views of lists.
Allows access to Enterprise Search results from client applications and Web applications outside of the context of a
Search /_vti_bin/search.asmx
SharePoint site.
The following link provides a summary of all the Web Services available in SharePoint MOSS 2007 SharePoint Web Services.
Microsoft does not recommend heavy use of SharePoint Web Services for updating SharePoint data, however, passive use of SharePoint Web Services to read service data is
considered acceptable.
Publishing a SharePoint Web Service on Presto
Having identified the SharePoint Web Service endpoint URL, we're able to publish the service as a Presto SOAP Service. Presto requres the URL of the Web Service WSDL
which we can get by appending ?wsdl to the Web Service Endpoint address.
The following information is required to publish a SOAP Service on Presto:
1. A URL for the Web Service WSDL, eg. for the Lists Web Service, http://www.mycompany.com/sites/MySite/_vti_bin/Lists.asmx?wsdl. The URL must include
the ?wsdl query.
2. NTLM credentials, username, password and domain.
Optionally:
• Choose an existing or create a new Presto Application to which the Service will be assigned.
• Select a Service Provider to be associated with the service.
• Choose one or more service Tags, for example you may wish to tag services with the name "SharePoint" and all services from a given site with the SharePoint
Site name.
Note that the initial service publishing stage will fail if the ?wsdl property is not included in the Web Service URL.
Password credentials are stored by Presto in encrypted form.
The full procedure for publishing a SOAP Service on Presto is detailed at Publishing a SOAP Service on Presto, located here,
http://www.jackbe.com/prestodocs/v2.6.1/prestolibrary/wwhelp/wwhimpl/js/html/wwhelp.htm.
Having published and activated the service, the service is now mashable, which we'll discuss in the next article, Mashing SharePoint Web Services.
26
Part 2.4: Mashing SharePoint Web Services
This is the ninth in a many-part series about Mashups and Microsoft SharePoint. You can read about the entire series at http://www.jackbe.com/enterprise-
mashup/blog/mashing-sharepoint-introduction.
This section provides 2 examples of publishing a SharePoint Web Service with Presto, using Wires to Virtualize the Web Service and create a Mashup, and finally to expose the
Mashup as a Mashlet.
So we have a 3 stage procedure:
1. Publish the Web Service on Presto using Service Explorer.
2. Create and publish a Mashup, virtualizing a Web Service Operation using Wires.
3. Create and publish a Mashlet of the Mashup using MashletMaker.
Some of the SharePoint Web Service WSDLs do not fully describe the inputs and outputs to the service operations, for example the WSDL may describe an input parameter as a
primitive string whereas the service is expects the client to provide a complex fragment of xml.
Preferabely the WSDL would fully describe operation inputs down to their primitive parts, Presto is dependent on the WSDL service description in order to build the various user
interface components through which the user can enter input data.
The operations exposed by a SharePoint Web Service can be viewed in a Browser by entering the Web Service URL, the Web Service will return the Web Service Description in
a browser readable form. Each listed operation provides a link to a description of the request and response message composition.
In some circumstances the WSDL will not fully describe the service operation input or output messages, as is the case with the SharePoint Search WSDL, MSDN can be used to
track down the necessary detail.
SharePoint List Web Service
The Lists Web Service is probably one of the most useful Web Services SharePoint provides, it exposes various operations enabling us to request details of any identifiable list
based service maintained by a SharePoint Site. (The Lists Wb Serivces is located at http://msdn.microsoft.com/en-us/library/lists.aspx)
• GetListCollection can be used to retrieve a summary list of all Lists maintained by a SharePoint Site
• GetList can be used to retrieve the details of the Fields which compose a named List.
• GetListItems can be used to retreive the content of a named List.
Publishing The Lists Web Service to Presto
Before publishing the Web Service to Presto we need to gather the following information, assuming we have a SharePoint Site namedJackbe :
• A name to uniquely identify the published Presto Service, eg. SpJackbeLists, signifying Sharepoint Service, Jackbe Site, Lists Web Service.
• The URL for the service WSDL, eg. http://www.mycompany.com/sites/MySite/_vti_bin/Lists.asmx?wsdl.
• NT Lan Manager (NTLM) Username, password and domain.
Using Presto Service Explorer, we launch the WSDL publishing wizard and enter our details, select NTLM authentication and enter our user credentials. The screenshot below
shows an example of the Service details entered in the Service Explorer Publishing Wizard:
27
Presto will access the service, read and validate the WSDL and prepare the Service as a Presto Published Service. If successful, the wizard will stop to allow us to configure role
based access to the service as a whole and/or to individual operations, as illustrated in the screenshot below:
Having published the service, by default the service will be activated and ready to be invoked, we are now ready to use the service as a Mashable in Wires.
Note that if you try to create a Mashlet directly from the published Web Service using MashletMaker then you will probably find that when you select a Service
Operation, GetList for example, MashletMaker will recommend that you virtualize the Operation using Wires becuase the Operation input parameters are complex.
Virtualization is process by which Wires is able to convert complex input parameters into one or more primitive datatype input parameters.
Create and Publish a Mashup
As a very simple example, we will expose the newly published service, GetListItems Operation as a mashup Service.
See Creating Mashups for further details explaining how to use Wires to create Mashups. (located here,
http://www.jackbe.com/prestodocs/v2.6.1/prestolibrary/wwhelp/wwhimpl/api.htm?href=PrestoLibrary.1.114.html)
• Having launched Wires, locate the newly published Service in the Service pallette.
• Drag the service out onto the canvas and select the GetListItems operation from the drop down list.
28
The screenshot below shows the complex Input Parameter details for the GetListItems Operation.
• Most of the parameters are optional and we can leave them blank, but we will virtualize the listName parameter by clicking the pipe icon which appears
to the right of the input field when the mouse passes over. The virtualized input parameter will appear as a new block on the canvas, connected to the Service
block.
• We can test these 2 blocks by entering the name or GUID of a List in the Input Parameter block.
• To complete the Mashup we connect the Service block to the Mashup Output block.
• We can now save the Mashup, assigning a unique name to it, tagging and providing a description.
• Having saved the Mashup we can publish it so that it becomes externally accessible.
The screenshot below shows the completed mashup.
Having published the Mashup we can now expose the Mashup as a Mashlet. Once the mashup is published, Wires provides us with a shortcut via a toolbar button to create a
Mashlet from the current Mashup.
Create and Publish a Mashlet
The Mashup we created takes a single string input parameter which identifies the name of the list we wish to view.
On our example SharePoint Site, Jackbe, we have a Tasks List which maintains a summary of tasks assigned to various team members. This List is shown in the screenshot
below, it only contains 2 entries, Task A and Task B.
29
We will create a Mashlet which exposes this List as a Mashlet so that the information can be made available to users outside the sharePoint environment.
• Launch MashletMaker, either from within Wires or via the Presto Home page.
• Select the virtualized GetListItem Mashup previously published.
• Select the single operation exposed by the mashup, runMashup.
• MashletMaker will display any inputs required by the Mashup, it should display the single input parameter, listName.
• We enter the name of the List we which to view, in our case we'll enter the name Tasks.
• MashletMaker will now prompt us to select the type of View we wish to use, select GridView.
• MashletMaker will now invoke the service and prompt us to select which data columns are to appear in the GridView. In our example we select columns to display
task Name, Id and Status.
• Mashlet Maker will now render the mashlet as shown in the screenshot below.
• We can now choose to publish the mashlet or further alter it by modifying mashlet appearance or role based security setting.
SharePoint Search Web Service
The Search Web Service enables us to perform search queries across a SharePoint Site. Here we'll demonstrate how we can use the Web Service Query Operation to search
for occurances of a key word or phrase on a SharePoint Site and for those results to be made available in the form of an RSS Feed. (The Search Web Service is located here,
http://msdn.microsoft.com/en-us/library/search.aspx)
Publishing The Search Web Service to Presto
Before publishing the Web Service to Presto we need to gather the following information, assuming we have a SharePoint Site namedJackbe :
• A name to uniquely identify the published Presto Service, eg. SpJackbeSearch, signifying Sharepoint Service, Jackbe Site, SearchWeb Service.
• The URL for the service WSDL, eg. http://www.mycompany.com/sites/MySite/_vti_bin/Search.asmx?wsdl.
• NT Lan Manager (NTLM) Username, password and domain.
30
Using Presto Service Explorer, we launch the WSDL publishing wizard and enter our details, select NTLM authentication and enter our user credentials. The screenshot below
shows an example of the Service details entered in the Service Explorer Publishing Wizard:
Presto will access the service, read and validate the WSDL and prepare the Service as a Presto Published Service. If successful, the wizard will stop to allow us to configure role
based access to the service as a whole and/or to individual operations, as illustrated in the screenshot below:
Having published the service, by default the service will be activated and ready to be invoked, we are now ready to use the service as a Mashable in Wires.
31
Note that if you try to create a Mashlet directly from the published Web Service using MashletMaker then you will probably find that when you select a Service
Operation, Query for example, MashletMaker will recommend that you virtualize the Operation using Wires becuase the Operation input parameters are complex.
Virtualization is process by which Wires is able to convert complex input parameters into one or more primitive datatype input parameters.
Create and Publish a Mashup
We will expose the newly published service, Query Operation as a mashup Service.
See Creating Mashups for further details explaining how to use Wires to create Mashups.
• Having launched Wires, locate the newly published Service in the Service pallette.
• Drag the service out onto the canvas and select the Query operation from the drop down list.
The screenshot below shows the complex Input Parameter details for the Query Operation, The Input Parameter expects the user to enter the queryXml as a string.
Unfortunately, the service WSDL schema does not define the content of the queryXml parameter, the parameter must specify a fragment of XML encapsualted as a QueryPacket.
Here is an example :
urn:Microsoft.Search.Response.Document.Document
Jackbe
The only part we are interested in is the QueryText element content, Jackbe, in the above example.
With Wires being unable to help us build this fragment of XML we are forced to build the XML fragment and then cut and paste it as a string into the input field for the Seach block,
as shown below. We can then invoke the search and see what search results are returned.
By default when the search is invoked the preview window will display the response document as a structured XML Tree, unfortunately, as with the Operation Input Parameter,
the WSDL Schema does not go as far as defining the content of the Search Response QueryResult, it just defines it as an opaque string.
32
By switching to the Text view of the response we can see that the QueryResult contains a CDATA element which in turn contains a ResponsePacket element, encapsulating the
Search Result.
We can use the Wires ExtractValue Action to extract this QueryResult value in order to process the Search Result in XML form, as shown in the screenshot below. Now the XML
Tree View of the extracted SearchResult ResponsePacket shows us that the Search returned a list of Document elements encapsulating each search result item.
Going back to the Search Query Input Parameter, we dont really want to force the user to have to enter the entire fragment of XML each time they perform a search, ideally, we
would provide a template Action which constructs the XML Fragment and inserts the Query Text.
We can add such a Template Action and add it to our Wires pallette relatively easily. Instructions on how to add a new Action to Wires are details in this MDC Blog entry by
Kishore, located at, http://www.jackbe.com/enterprise-mashup/blog/create-rss-feed-any-service-output, it explains how we can create a new macro which we add to the
global.emml-macros file, which is used by wires to populate the Action Pallette.
I've created the following macro, QueryPacketTemplate, which just takes a string input, which will be our query text, and creates a fragment of XML as a string, which we can
then wire to out SpJackbeSearch Block in Wires.
user
template
Query Text
build Search Query
Search Query Text
'+
''+
'urn:Microsoft.Search.Response.Document.Document'+
''+
''+
query +
''+
''+
''+
'';
]]>
Presto must be restarted if the global.emml-macros file is updated.
33
The screenshot below shows the completed mashup, the new QueryPacketTemplate action is fed by an Input Parameter block which takes a simple string value as the query text.
Create and Publish Search Mashlet
We will create a Mashlet which exposes this Search Mashup as a Mashlet so that the search capability can be made available to users outside the SharePoint environment.
• Launch MashletMaker, either from within Wires or via the Presto Home page.
• Select the Search Mashup previously published.
• Select the single operation exposed by the mashup, runMashup.
• MashletMaker will display any inputs required by the Mashup, it should display the single input parameter, named Input.
• We enter a default query string, Jackbe.
• MashletMaker will now prompt us to select the type of View we wish to use, select GridView.
• MashletMaker will now invoke the service and prompt us to select which data columns are to appear in the GridView. In our example we select columns to display
Title, Link and Date.
34
• The Mashlet Preview and Preferences will now be displayed.
• In the Mashlet Additional Preferences Section, we must change the preference disableRemotePaging from the default value of false to true, as shown in the
screen shot below.
• Click the Preview Changes button and the Mashlet should render.
• We can now choose to publish the mashlet or further alter it by modifying mashlet appearance or role based security setting.
Ideally the Mashlet would be intelligent enough to convert the Search result Link URLs into clickable links.
35
More information about Mashups for Microsoft SharePoint, along with a free developer
edition of the Presto Enterprise Mashup Platform used in the examples, can be
downloaded from the Mashup Developer Community at www.jackbe.com/dev.
36