Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 778

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="2. Installation Guide" />
  <meta name="dc.subject" content="2. Installation Guide" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="installation.html" title="Chapter Contents" />
  <link rel="prev" href="installwfas.html" title="Windows Form Application for accessing Virtuoso RDF data via SPASQL using the Virtuoso ADO.Net Provider" />
  <link rel="next" href="installsilver.html" title="Creating a Silverlight Application to consume the service" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>2. Installation Guide</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="installcrweb" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>2. Installation Guide</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="installation.html">Chapter Contents</a> | <a class="link" href="installwfas.html" title="Windows Form Application for accessing Virtuoso RDF data via SPASQL using the Virtuoso ADO.Net Provider">Prev</a> | <a class="link" href="installsilver.html" title="Creating a Silverlight Application to consume the service">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div class="selected">
      <a href="installation.html">Installation Guide</a>
   </div>
    <br />
   <div>
      <a href="installwin32.html">Virtuoso for Windows</a>
   </div>
   <div>
      <a href="linuxinstall.html">Virtuoso for Linux (Enterprise Edition)</a>
   </div>
   <div>
      <a href="unxinstvirt.html">Virtuoso for Unix (Enterprise Edition)</a>
   </div>
   <div>
      <a href="unixpersonainstall.html">Virtuoso for Unix (Personal Edition)</a>
   </div>
   <div>
      <a href="installmacosx.html">Virtuoso for Mac OS X</a>
   </div>
   <div>
      <a href="installvsgrid.html">Virtuoso ADO.Net Data Grid Form Application</a>
   </div>
   <div>
      <a href="installvsent.html">Using Visual Studio 2008 to Build an Entity Frameworks based Windows Form Application</a>
   </div>
   <div>
      <a href="installusado.html">Using Visual Studio 2008 to Build an ADO.NET Data Services based Application</a>
   </div>
   <div>
      <a href="installwfas.html">Windows Form Application for accessing Virtuoso RDF data via SPASQL using the Virtuoso ADO.Net Provider</a>
   </div>
   <div class="selected">
      <a href="installcrweb.html">Creating a Web Browser Application to Access RDF Data Using The Virtuoso ADO.Net Provider</a>
    <div>
        <a href="#installcrwebintro" title="Pre-requisites">Pre-requisites</a>
        <a href="#installcrwebcrserv" title="Creating the Web Service">Creating the Web Service</a>
        <a href="#installcrbrappl" title="Creating the Browser Application">Creating the Browser Application</a>
        <a href="#installcrwebiis" title="Deploy With IIS">Deploy With IIS</a>
    </div>
   </div>
   <div>
      <a href="installsilver.html">Creating a Silverlight Application to consume the service</a>
   </div>
   <div>
      <a href="installnetriadd.html">Creating A Simple .NET RIA Services Application To Display Data
From Virtuoso</a>
   </div>
   <div>
      <a href="installnetriavd.html">Creating a .Net RIA Services Application That Will Update Virtuoso Data</a>
   </div>
   <div>
      <a href="clusterstcnf.html">Cluster Installation and Config</a>
   </div>
    <br />
  </div>
  <div id="text">
  <a name="installcrweb" />
    <h2>2.10. Creating a Web Browser Application to Access RDF Data Using The Virtuoso ADO.Net Provider</h2>
<p>This section will guide you through creating first a Web Service that exposes RDF data from Virtuoso
and then a simple web browser application that consumes the Web Service and allowing you to access and
explore the RDF data by clicking on dereferenceable <a href="rdfdatarepresentation.html#rdfiriidtype">IRIs</a>.
</p>

      <a name="installcrwebintro" />
    <h3>2.10.1. Pre-requisites</h3>
<ol>
      <li>The example assumes that you have a local Virtuoso server with the Northwind demo database
installed. If the demo database is not already installed then download the <a href="http://download.openlinksw.com/packages/5.0/virtuoso/demo_dav.vad">demo database VAD package</a>
(demo_dav.vad) and install it. The VAD package will create a new database in Virtuoso called demo
containing the familiar Northwind tables. It will also creates <a href="http://docs.openlinksw.com/virtuoso/rdfsparqlintegrationmiddleware.html#rdfviews">RDF views</a> of the Northwind tables.
In the example we assume the database is accessible on a hostname of &quot;demo.openlinksw.com&quot; on the
default port 80, where an actually live instance of the Virtuoso Demo database is hosted. Users would
use the appropriate hostname and port number of their Virtuoso installation to create the sample
application, and would be would be localhost:8890 for a default installation or whatever the <a href="sect5_ini_URIQA.html">URIQA DefaultHost</a>
Virtuoso configuration parameter is set to when the demo database VAD package is installed.
  </li>
      <li>The Virtuoso ADO.Net provider for .Net 3.5 and the Entity Framework.</li>
      <li>Microsoft Visual Studio 2008</li>
      <li>The Virtuoso <a href="">RDF Mappers VAD package</a>.</li>
    </ol>
    <br />
    
      <a name="installcrwebcrserv" />
    <h3>2.10.2. Creating the Web Service</h3>
    <p>
      <strong>Step 1 - Create a view of the RDF data</strong>
    </p>
<p>To create a view of the customers in the Northwind first open the Virtuoso Conductor and log in as
dba. Then open iSQL from the menu on the left and execute the following statement.
</p>
<div>
      <pre class="programlisting">
create view Demo.demo.sparqlview as
sparql
select distinct ?s  from &lt;http://localhost:8890/Northwind&gt;
where {?s a &lt;http://demo.openlinksw.com/schemas/northwind#Customer&gt;}
</pre>
    </div>
    <p>Note:</p>
    <ul>
      <li>If the view is added to the Visual Studio project as user &quot;demo&quot; (or any other than &quot;dba&#39;),
then it must be ensured that the &quot;SPARQL_SELECT&quot; and &quot;SPARQL_SPONGE&quot; roles are assigned to this user, which
can be done via the Virtuoso Conductor in the &quot;System Admin&quot; -&gt; &quot;User Accounts&quot; tab. </li>
      <li>Execute permissions will also need to be granted to the following procedure:
<div>
          <pre class="programlisting">
grant execute on DB.DBA.RDF_MAKE_LONG_OF_SQLVAL to &quot;demo&quot;
</pre>
        </div>
      </li>
    </ul>
        <table class="figure" border="0" cellpadding="0" cellspacing="0">
    <tr>
     <td>
          <img alt="create a view" src="../images/ui/sparqlwinf25.png" />
     </td>
    </tr>
    <tr>
        <td>Figure: 2.10.2.1. create a view</td>
    </tr>
    </table>
    <p>
      <strong>Step 2 - Create the Visual Studio Project and Add the Model</strong>
    </p>
<ol>
      <li>Open <strong>Visual Studio</strong> and create a new <strong>ASP .NET Web Application
</strong> called RDFWebDemo.
    <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="create new application" src="../images/ui/sparqlwinf26.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.10.2.1. create new application</td>
      </tr>
        </table>
</li>
      <li>Right click RDFWebDemo in the <strong>Solution Explorer</strong> and add a new
<strong>ADO.NET Entity Data Model</strong> called Model1.edmx.
This will open the Entity Data Model Wizard.</li>
      <li>Choose <strong>Generate From Database</strong> and click <strong>Next</strong>.</li>
      <li>Set up a connection to the Demo database on your local Virtuoso Server, select
<strong>Yes, include the sensitive data in the connection string</strong> and set the name of the
entities to DemoEntities. Click <strong>Next</strong>.</li>
      <li>On the <strong>Choose Your Database Objects</strong> page expand <strong>Views</strong>
and select sparqlview. Check that the Model Namespace is DemoModel and click Finish.
    <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="Model Namespace" src="../images/ui/sparqlwinf27.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.10.2.1. Model Namespace</td>
      </tr>
        </table>
</li>
    </ol>
<p>
</p>
    <p>
      <strong>Step 3 - Add the Web Service</strong>
    </p>
<ol>
      <li>Right click RDFWebDemo in the <strong>Solution Explorer</strong> and add a new
<strong>ADO.NET Data Service</strong> called WebDataService1.svc. Click <strong>Add</strong>.</li>
      <li>In the class definition of WebDataService1 in the newly created file WebDataService1.svc.cs replace /* TODO: put your data source class name here */ with the name of our model, DemoEntities.
<div>
          <pre class="programlisting">
public class WebDataService1 : DataService&lt;DemoEntities&gt;
</pre>
        </div>
</li>
      <li>In the InitializeService method add the line:
<div>
          <pre class="programlisting">
config.SetEntitySetAccessRule(&quot;*&quot;, EntitySetRights.All);
</pre>
        </div>
<p>The method should look like this:
</p>
<div>
          <pre class="programlisting">
 public static void InitializeService(IDataServiceConfiguration config)
   {
       // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
       // Examples:
       // config.SetEntitySetAccessRule(&quot;MyEntityset&quot;, EntitySetRights.AllRead);
       // config.SetServiceOperationAccessRule(&quot;MyServiceOperation&quot;, ServiceOperationRights.All);

       config.SetEntitySetAccessRule(&quot;*&quot;, EntitySetRights.All);
   }
</pre>
        </div>
</li>
    </ol>
    <p>
      <strong>Step 4 - Compile and Run</strong>
    </p>
<p>Hit <strong>F5</strong> to compile and run the service. Select <strong>OK</strong> when
prompted to enable debugging. The default browser will be launched showing a page like:
</p>
<div>
      <pre class="programlisting">
  &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; standalone=&quot;yes&quot; ?&gt;
- &lt;service xml:base=&quot;http://localhost:1241/WebDataService1.svc/&quot; xmlns:atom=&quot;http://www.w3.org/2005/Atom&quot; xmlns:app=&quot;http://www.w3.org/2007/app&quot; xmlns=&quot;http://www.w3.org/2007/app&quot;&gt;
- &lt;workspace&gt;
  &lt;atom:title&gt;Default&lt;/atom:title&gt;
- &lt;collection href=&quot;sparqlview&quot;&gt;
  &lt;atom:title&gt;sparqlview&lt;/atom:title&gt;
  &lt;/collection&gt;
  &lt;/workspace&gt;
  &lt;/service&gt;
</pre>
    </div>
<p>The service is now running.
</p>
<p>Note the address on which the service is made available. You will need to know this when creating
the app to consume the service. Look in the Address Bar of the browser. It will be something like:
http://localhost:1492/WebDataService1.svc/
</p>
    <br />
    
      <a name="installcrbrappl" />
    <h3>2.10.3. Creating the Browser Application</h3>
<p>
      <strong>Step 1 - Create the Visual Studio Project.</strong>
    </p>
<ol>
      <li>Open <strong>Visual Studio</strong> and create a new
<strong>ASP.NET Web Application</strong> called RDFWebApp.
    <table class="figure" border="0" cellpadding="0" cellspacing="0">
      <tr>
       <td>
              <img alt="New Web Application" src="../images/ui/sparqlwinf28.png" />
       </td>
      </tr>
      <tr>
            <td>Figure: 2.10.3.1. New Web Application</td>
      </tr>
        </table>
</li>
      <li>Create client side entities with datasvcutil.exe
<ul>
  <li>Open a command prompt.</li>
  <li>Navigate to *C:\WINDOWS\Microsoft.NET\Framework\v3.5*.</li>
  <li>Generate the client classes using the following command:
<div>
              <pre class="programlisting">
datasvcutil.exe /uri:http://localhost:1492/WebDataService1.svc /out:DemoEntities.cs
</pre>
            </div>
<p>Note the address of the service - you may need to change the port number to
match the one seen in the address at the end of Step 4 in Creating the Web Service.
</p>
</li>
</ul>
</li>
      <li>Add the classes to RDFWebApp.
<ul>
  <li>Right click RDFWebApp</li>
  <li>Choose to add an existing item and add c:\WINDOWS\Microsoft.NET\Framework\v3.5\DemoEntities.cs.</li>
</ul>
</li>
      <li>Add a reference to System.Data.Services.Client to the project.</li>
    </ol>
<p>
</p>
    <p>
      <strong>Step 2 - Display the contents of sparqlview as a table on the page</strong>
    </p>
<p>To display the RDF data on the web page we create a table with a row for each item in sparqlview.
We then use each IRI from sparqlview to create a hyperlink. The hyperlinks are displayed in the table
cells. To do this add the following block of code to the page_load method in Default.aspx.cs.
</p>
<div>
      <pre class="programlisting">
 DemoModel.DemoEntities svc = new DemoModel.DemoEntities(new Uri(&quot;http://localhost:1492/WebDataService1.svc&quot;));

  var query = svc.sparqlview;
  Table iriTable = new Table();
  this.Controls.Add(iriTable);

  foreach (DemoModel.sparqlview sv in query)
  {
      TableRow tRow = new TableRow();
      iriTable.Rows.Add(tRow);
      TableCell tCell = new TableCell();
      tRow.Cells.Add(tCell);
      HyperLink h = new HyperLink();
      h.Text = sv.s;
      h.NavigateUrl = sv.s;
      tCell.Controls.Add(h);
  }
</pre>
    </div>
<p>Note the address of the service in the first line - you may need to change the port number to match
the one seen in the address at the end of Step 4 in Creating the Web Service.
</p>
<p>Compile and run RDFWebApp (ensuring that the service created above is still running). This will
launch a browser and display the IRIs from sparqlview as a list of hyperlinks.
</p>
    <table class="figure" border="0" cellpadding="0" cellspacing="0">
    <tr>
     <td>
          <img alt="list of hyperlinks" src="../images/ui/sparqlwinf29.png" />
     </td>
    </tr>
    <tr>
        <td>Figure: 2.10.3.1. list of hyperlinks</td>
    </tr>
    </table>
<p>With the <a href="http://download.openlinksw.com/packages/5.0/virtuoso/rdf_mappers_dav.vad">RDF Mappers VAD package</a> installed in Virtuoso, clicking on these
links will take you to a description page of the referenced resource. The description page is created
using <a href="http://virtuoso.openlinksw.com/Whitepapers/html/vdld_html/VirtDeployingLinkedDataGuide_Glossary.html#mozTocId13075">description.vsp</a>.
</p>
    <table class="figure" border="0" cellpadding="0" cellspacing="0">
    <tr>
     <td>
          <img alt="Description page" src="../images/ui/sparqlwinf30.png" />
     </td>
    </tr>
    <tr>
        <td>Figure: 2.10.3.2. Description page</td>
    </tr>
    </table>
    <br />
    <a name="installcrwebiis" />
    <h3>2.10.4. Deploy With IIS</h3>
<p>To create and test this simple Web Service we have used the Visual Studio Development Server. This
section describes how to deploy the service using IIS.
</p>
        <a name="installcrwebiiswebs" />
    <h4>2.10.4.1. Web Service</h4>
<p>To deploy the service using IIS:
</p>
    <ul>
  <li>Open the RDFWebDemo project in Visual Studio, go to the <strong>Project</strong> menu
and select RDFWebDemo <strong>Properties</strong>.</li>
  <li>Select the <strong>Web</strong> tab and scroll down to the <strong>Servers</strong>
section. Select <strong>Use local IIS Server</strong>. The project URL defaults to using localhost.</li>
  <li>Click the <strong>Create Virtual Directory</strong> button then check that the Service works on localhost.</li>
  <li>Build the project then start without debugging (ctrl F5).</li>
</ul>
<p>The start page that you see when you test the service will look the same as before but the address
in the browser bar will be something like http://localhost/RDFWebDemo1/WebDataService1.svc/. You can now
access your service remotely using the hostname or IP address of your server.
</p>
<p>If at this point you get an Access is denied error, 401.3, then you will need to add the Internet
Guest Account (IUSR_XXX where XXX is your computer name) to the users allowed to access the folder
containing the RDFWebDemo project.
</p>
        <br />
        <a name="installcrwebiisweba" />
    <h4>2.10.4.2. Web Application</h4>
<p>You will now need to modify RDFWebApp to access the service at the new address. At the same time
we will also change RDFWebApp so that it too is deployed using IIS
</p>
<ul>
  <li>Open The RDFWebApp project in Visual Studio.</li>
  <li>Go to the <strong>Project</strong> menu and select RDFWebApp <strong>Properties</strong>.</li>
  <li>Select the <strong>Web</strong> tab and scroll down to the <strong>Servers</strong>
section. Select <strong>Use local IIS Server</strong>. The project URL defaults to using localhost.</li>
  <li>Click the <strong>Create Virtual Directory</strong> button. The web application will then run on the local IIS.
<div>
          <pre class="programlisting">
DemoModel.DemoEntities svc = new DemoModel.DemoEntities(new Uri(&quot;http://localhost:1492/WebDataService1.svc&quot;));
</pre>
        </div>
<p>to
</p>
<div>
          <pre class="programlisting">
DemoModel.DemoEntities svc = new DemoModel.DemoEntities(new Uri(&quot;http://localhost/RDFWebDemo/WebDataService1.svc/&quot;));
</pre>
        </div>
</li>
  <li>To reference the web service running on IIS you will need to edit Default.aspx.cs. Change </li>
  <li>Build the project then start without debugging (ctrl F5).</li>
</ul>
<p>
The web application is accessible on http://localhost/RDFWebApp/Default.aspx and can also be accessed using
the hostname or IP address of you server e.g. http://192.168.7.129/RDFWebApp/Default.aspx
</p>
    <table class="figure" border="0" cellpadding="0" cellspacing="0">
    <tr>
     <td>
          <img alt="Default.aspx" src="../images/ui/sparqlwinf31.png" />
     </td>
    </tr>
    <tr>
        <td>Figure: 2.10.4.2.1. Default.aspx</td>
    </tr>
    </table>
    <br />
    <p>
      <strong>Next Steps</strong>
    </p>
<p>The next example shows you how to quickly create an ADO.Net Data Service that exposes RDF data in
Virtuoso and how to create a basic Web application to consume that service. The next step is to
<a href="installsilver.html">create a Silverlight Application to consume the same service</a>.
</p>
    <br />
  <table border="0" width="90%" id="navbarbottom">
    <tr>
        <td align="left" width="33%">
          <a href="installwfas.html" title="Windows Form Application for accessing Virtuoso RDF data via SPASQL using the Virtuoso ADO.Net Provider">Previous</a>
          <br />Windows Form Application for accessing Virtuoso RDF data via SPASQL using the Virtuoso ADO.Net Provider</td>
     <td align="center" width="34%">
          <a href="installation.html">Chapter Contents</a>
     </td>
        <td align="right" width="33%">
          <a href="installsilver.html" title="Creating a Silverlight Application to consume the service">Next</a>
          <br />Creating a Silverlight Application to consume the service</td>
    </tr>
    </table>
  </div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>