Background

Sample Technique Applies To

Technical Details

Sample Contents

Source Code

Deployment Files

Deployment Instructions

Using Batch File

Not Using Batch File

IIS setup

WSRP Producer set up

Background

In order to include Silverlight applications in the WSRP Producer for .NET you must take into account certain limitations imposed by WSRP with regards to Url rewriting. This sample shows you how to create a simple Silverlight 3 video player that accounts for this issue.

By default, Silverlight applications pass values from the client to the server using GET requests with query string parameters. For example, the Silverlight WebClient API’s download feature passes file information to the server as a GET request with query string parameters. WSRP Consumers proxy Urls by surrounding them with tokens and some WSRP Consumer portals, such as Oracle WebCenter, even add checksums to Urls. This makes it challenging to dynamically add query string parameters to Urls proxied through WSRP. This sample shows you one way to work around this issue.

Sample Technique Applies To:

- Any developer interested in creating a Silverlight application for display in a WSRP Consumer portal.
- Any developer working with the WSRP Producer for .NET interested in passing query string parameters via GET requests.

Technical Details

As mentioned in the Background section this sample works around an issue with Url rewriting. This sample should be looked at in terms of 2 parts: the Silverlight video player and the ASP.NET user control hosting the video player.

Silverlight Video Player

The Silverlight Video Player (MediaPlayer.xaml in source code) is a common implementation of a video player with the exception of how the method that invokes video playing is accessed. This method (SilverlightFunctionPlay) is marked as a ScriptableMember so that it can be made available to javascript.

Video Player Hosting Portlet – Video playing

The Video Player Hosting Portlet is set up as an ASP.NET user control, VideoWebUserControl.ascx. When it is first loaded it queries a SQL Server database for a list of videos. For each video it contructs an Url to a handler (webFileHandler.ashx) and puts the ID of the video (as stored in the database) as a query string argument. Each Url is placed in a hidden href and placed on the user control’s ASP.NET Page. This way, when the markup is returned it is properly transformed to a WSRP proxied Url. When the user selects a video and clicks “play” a javascript function passes the proxied Url to the “SilverlightFunctionPlay” method that has been made available to javascript (see Silverlight Video Player). The handler that is part of the proxied Url manages streaming of the selected video to the player.

Please review the Oracle® Fusion Middleware Development Guide for Oracle WebCenter WSRP Producer for .NET 11g for more detailed information on markup transformation. Also, look at the “Managing AJAX Outside the .NET Framework” tutorial in this same guide for another example of using hidden hrefs as a way to transform Urls into WSRP proxied Urls.

One important thing to note about the inclusion of the Silverlight application in VideoWebUserControl.ascx is that the height and width are fixed. In many Silverlight examples you will find on the web the height and width are set to a percentage. Due to differences in how various browsers handle HTML object layout and due to the fact that you will have little control on where your portlet is positioned in a portal page avoid using percentage values for height and width.

Video Player Hosting Portlet – Video uploading

Video uploading is managed through a standard ASP.NET FileUpload control. The file is streamed to a temporary location on the file system of the server (WSRP Producer for .NET host machine) and added to the list of videos returned as hidden anchor href values.

Sample Contents

The sample consists of 2 root folders, “src” and “deployment”. The “src” folder contains a Visual Studio 2008 solution that relies on the Silverlight 3 Tools for Visual Studio 2008 SP1. The solution contains 2 projects:

- SilverlightMediaPlayer – This is the Silverlight application
- SilverlightPortlets – This contains an ASP.NET user control that hosts the Silverlight application and is modified to accomodate for WSRP proxy limitations.

To load and compile the sample solution in Microsoft Visual Studio you must have:

- SQL Server
- Silverlight 3 Tools for Visual Studio 2008 SP1

The sample was created using the version of SQL Server Express set up by default for Visual Studio 2008. If you have SQL Server Express installed with Visual Studio 2008 no additional configuration is required to compile and run the sample. However, if you do not have SQL Server Express, you must modify the connectionStrings portion of web.config so that Database1.mdf in the App_Data folder is referenced.

The Visual Studio projects that make up the sample in the “src” directory specifically require the presence of the Silverlight Tools for Visual Studio 2008 SP1. Make sure that you download and install this toolkit before opening up the solution or you will get the following message:

“The project file SilverlightMediaPlayer.csproj cannot be opened. The project type is not supported by this installation.”

At the time of writing this sample, this link will take you to the Silverlight 3 Tools installer. Oracle makes no guarantees on the availability of this link. This link is provided by Microsoft and may become unavailable at any time. In that case, you will need to search for the Silverlight 3 Tools yourself.

WARNING about Silverlight 3 Tools and installation on networks that use a proxy server:

The Silverlight 3 Tools installer from Microsoft failed for this author when installing on a network with a proxy server. The tools installer reported “WinHttpConnect failed with error: 12005” in the MSI installation log. To work around the issue you must run the tools offline or take your machine to a network or workgroup that is not guarded by a proxy server. Here are the steps the author of this document performed to run the installer in off-line mode:

1. Go to %tmp% and create a “Silverlight 3.0 Tools” folder if not already present.
2. Copy the Silverlight3_Tools.exe there.
3. Locate a copy of Silverlight_Developer.exe for Silverlight 3. The author of this document found a copy at http://blogs.ppedv.de/hannesp/archive/Silverlight-Download-Links. If this link is still valid then click on the “Developer Runtime Download.”
4. Copy Silverlight_Developer.exe you located to %tmp%\Silverlight 3.0 Tools folder.
5. Run the Silverlight3_Tools.exe from this location.

Please note that if you are interested only in deploying the sample and not compiling it yourself or viewing the source code in Visual Studio then you do not need to download the Silverlight 3 Tools.

The Visual Studio solution for this sample sets the proper build order (SilverlightMediaPlayer followed by SilverlightPortlets) so that the .xap file generated for the media player is placed in the ClientBin directory of the “SilverlightPortlets” project. Once compiled, run the IIS setup steps described in the Deployment Instructions (see IIS set up instructions)

The “deployment” folder contains files useful for deploying the sample to the WSRP Producer for .NET (please review the Oracle® Fusion Middleware Development Guide for Oracle WebCenter WSRP Producer for .NET 11g for more detailed information on deploying portlets and using regular expressions for markup transformation):

- The “SilverlightWSRPPortlets” folder contains content relevant to the system hosting the WSRP Producer for .NET. This includes:

- App_Data folder containing database files used by the sample.
- wsrp-producer.xml with

- a ruleset including .xap in the href regex so that the Silverlight Application is proxied as a WSRP http resource
- a ruleset including .ashx so that the handler that returns Urls to the videos is proxied as a WSRP http resource
- a <portlet> node containing information on just this sample’s portlet

- Web.config that references the database placed in the App_Data folder. With the exception of the database reference this file should be nearly identical to the default Web.config laid down by the WSRP Producer for .NET installer under “wsrpdefault”.
- clientaccesspolicy.xml that prevents any cross-domain issues if you decide not to include the ruleset in wsrp-producer.xml that proxies the .xap file as a WSRP http resource. This file is not needed in the default set up.

Deployment Instructions

The following deployment instructions are for running the sample on a WSRP Consumer portal such as Oracle WebCenter or Oracle WebLogic Portal. NOTE: When the instructions refer to “<sampledir>” they are referring to the directory location where you unzipped this sample.

SQL Server database requirement

As mention in Sample Contents section of this document, this sample requires that SQL Server Express or SQL Server be installed so that the database included in the App_Data folder can be utilized. If you have Visual Studio 2008 present with the default SQL Server Express installed, you do not have to perform any additional configuration. Otherwise, you must modify the connectionStrings portion of web.config so that Database1.mdf in the App_Data folder is referenced.

Using the setup batch file to run default set up

If you are on the same machine where you installed the Oracle WSRP Producer for .NET then you can use a batch file to deploy the sample. If you click on <sampledir>\deployment\setup.bat the script will:

- Copy all files from the WSRP Producer for .NET installation to the <sampledir>\deployment\SilverlightWSRPPortlets that are needed to set up this location as a .NET WSRP producer.
- Setup IIS so that SilverlightWSRPPortlets is under a virtual directory with the proper file permissions.
- Update Urls in WSDL and portlet to account for deployment location.

If you are running the sample on IIS 6.0 (Windows 2003) you must make sure that the .xap extension is mapped to silverlight applications. Otherwise, clients of your Silverlight Application will get a 2104 Initialize Error. To add the proper mapping in IIS 6.0:

1. Open up “Internet Information Services Manager”
2. Right click on the local computer and select properties
3. Click on “MIME Types…” button.
4. If .xap is not already listed add a new MIME Type with extension of “.xap” and MIME type of “application/x-silverlight-app”.
5. Reset IIS from command line with iisreset command.

For IIS 7.0 and above .xap files are mapped properly by default.

WARNING: If you have installed the Oracle WSRP Producer for .NET in a folder with spaces in the path or unpacked the sample in a folder with spaces in the path, the default setup.bat will not work properly. To work around this issue:

- Construct paths without spaces by either

- Using the subst DOS command to create a drive letter mapping to the location with spaces in it.
- Running <sampledir>\deployment\SampleDeploymentHelper.exe ShortName “<the path with spaces>” to get the DOS short name for the path with spaces.

- Open up setup.bat and set

- the no-spaces path to <sampledir>\deployment as CURRENTPATH
- the no-spaces path to the root WSRP Producer for .NET as PRODUCTINSTALL.
- Be sure to place a trailing “\” in all locations.

Setting up the sample without the batch file

These instructions are only required if you did not want to deploy the sample using the batch file.

IIS set up instructions

1. Copy the SilverlightWSRPPortlets folder from your <sampledir>\deployment folder or <sampledir>\src folder, if you compiled the sample yourself, and set the appropriate file permissions for running the project in IIS.

[Assuming that you have a default IIS set up the suggested file permissions are EVERYONE Read access and “NETWORK SERVICE” user Modify access.]

2. Create a virtual directory for the SilverlightWSRPPortlets with an IIS application:

1. Allow at least Script execute permissions
2. [IIS 7.x] application pool with ASP.NET v2.0.50727 registered and NetworkService assignment
3. [IIS 6.0] virtual directory has ASP.NET v2.0.50727 web service extensions registered and assigned to it.

3. Map MIME type for .xap extension to silverlight:

1. [IIS 7.x] By default, this should already be done.
2. [IIS 6.0] Map the .xap extension to the MIME type “application/x-silverlight-app”. Click here for instructions.

.NET WSRP Producer set up instructions

The following instructions are based on the standard instructions for “Adding an ASP.NET Application” in the Oracle® Fusion Middleware Development Guide for Oracle WebCenter WSRP Producer for Microsoft .NET 11g.

1. Locate VideoPortlet.aspx either under the “src” or the “deployment” folder.
2. Make sure that the <head> and <body> portions are removed and replaced with references to the ASP.NET master page you are using. Refer to the <sampledir>\ deployment\SilverlightWSRPPortlets\portlets\Silverlight_sample\VideoPortlet.aspx for an example.

[If you are working with the “wsrpdefault” virtual directory created for you by the Oracle WSRP Producer for .NET simply copy the <sampledir>\deployment\SilverlightWSRPPortlets\portlets folder contents to the portlets directory of your WSRP Producer for .NET installation’s wsrpdefault directory.]

3. Update wsrp-producer.xml to have a new ruleset based off of "default" ruleset that adds in the .ashx to list of matching files for href's. Refer to the “Silverlight” ruleset in <sampledir>\deployment\ SilverlightWSRPPortlets\wsrp-producer.xml for an example.
4. Update the ruleset you added in the previous step to apply a new rewriter rule that searches for the regular expression (name=\"source\" value=\")([^\"]+) and changes any .xap extensions that match this regular expression to be WSRP proxied resource Urls. Refer to the “Silverlight” ruleset in <sampledir>\deployment\ SilverlightWSRPPortlets\wsrp-producer.xml for an example.
5. Update wsrp-producer.xml with <portlet> entry for VideoPortlet.aspx. Refer to the <sampledir>\deployment\ SilverlightWSRPPortlets\wsrp-producer.xml for an example.
6. Register the WSRP Producer for .NET WSRP producer WSDL with your WSRP Consumer portal