. "2017-06-13T05:40:57.386082"^^ . "VirtSPASQLWebDataServiceApp" . . . "VirtSPASQLWebDataServiceApp" . . . "8736e83a5ee7cf82c5756705607465dc" . . . . . . . . . "%META:TOPICPARENT{name=\"VirtAdoNet35Provider\"}%\n\n---+ Creating a Web Browser Application to Access RDF Data Using The Virtuoso ADO.NET Provider\n\n%TOC%\n\n---++ Introduction\n\nThis document will guide you through creating first a Web Service that exposes RDF data from \nVirtuoso and then a simple web browser application that consumes the Web Service and allowing \nyou to access and explore the RDF data by clicking on dereferenceable \n[[http://docs.openlinksw.com/virtuoso/rdfdatarepresentation.html#rdfiriidtype][IRIs]]. \n\n---++ Prerequisites\n\n 1 Microsoft Visual Studio 2008\n 1 The Virtuoso ADO.NET provider for .NET 3.5 and the Entity Framework\n 1 The Virtuoso \n[[http://s3.amazonaws.com/opldownload/uda/vad-packages/6.1/virtuoso/cartridges_dav.vad][Cartridges VAD package]]\n 1 The example assumes that you have a local Virtuoso server with the Northwind demo database \ninstalled. If the demo database is not already installed then download the \n[[http://s3.amazonaws.com/opldownload/uda/vad-packages/6.1/virtuoso/demo_dav.vad][demo database VAD package]] \n(demo_dav.vad) and install it. The VAD package will create a new database in Virtuoso called demo \ncontaining the familiar Northwind tables. It will also create \n[[http://docs.openlinksw.com/virtuoso/rdfsparqlintegrationmiddleware.html#rdfviews][Linked Data Views]] \nof the Northwind tables. In the example we assume the database is accessible on a hostname of \n\"demo.openlinksw.com\" on the default port 80, where an actually live instance of the Virtuoso Demo \ndatabase is hosted. Users would use the appropriate hostname and port number of their Virtuoso \ninstallation to create the sample application, and would be would be localhost:8890 for a default \ninstallation or whatever the URIQA DefaultHost Virtuoso configuration parameter \nis set to when the demo database VAD package is installed. \n\n---++ Creating the Web Service\n\n---+++ Step 1 - Create a view of the RDF data\n\nTo create a view of the customers in the Northwind first open the Virtuoso Conductor and log \nin as dba. Then open iSQL from the menu on the left \nand execute the following statement.\n\nCREATE VIEW Demo.demo.sparqlview AS \n SPARQL\n PREFIX nwind: \n SELECT DISTINCT ?s \n FROM \n WHERE { ?s a nwind:Customer }\n\n\n*Note*: \n * If the view is added to the Visual Studio project as user \"demo\" (or any other \nthan \"dba'), then it must be ensured that the \"SPARQL_SELECT\" and \n\"SPARQL_SPONGE\" roles are assigned to this user, which can be done via the Virtuoso \nConductor in the System Admin -> User Accounts tab.\n * Execute permissions will also need to be granted to the RDF_MAKE_LONG_OF_SQLVAL procedure, \nwith an iSQL statement similar to the following:\n\nGRANT EXECUTE \n ON DB.DBA.RDF_MAKE_LONG_OF_SQLVAL \n TO \"demo\"\n\n%BR%%BR%%BR%%BR%\n\n---+++ Step 2 - Create the Visual Studio Project and Add the Model\n\n 1 Open Visual Studio and create a new ASP .NET Web Application called \n>RDFWebDemo.\n %BR%%BR%%BR%%BR%\n 1 Right-click RDFWebDemo in the Solution Explorer, and add \na new ADO.NET Entity Data Model called Model1.edmx. \nThis will open the Entity Data Model Wizard.\n 1 Choose Generate From Database and click Next.\n 1 Set up a connection to the Demo database on your local Virtuoso Server, select Yes, \ninclude the sensitive data in the connection string and set the name of the entities to \nDemoEntities. Click Next.\n 1 On the Choose Your Database Objects page expand Views and select \nsparqlview. Check that the Model Namespace is \nDemoModel and click Finish.\n%BR%%BR%%BR%%BR%\n \n---+++ Step 3 - Add the Web Service\n\n 1 Right click RDFWebDemo in the Solution Explorer and add \na new ADO.NET Data Service called WebDataService1.svc. \nClick Add.\n 1 In the class definition of WebDataService1 in the newly created \nfile WebDataService1.svc.cs replace \"/* TODO: put \nyour data source class name here */\" with the name of our model,\nDemoEntities.\n\npublic class WebDataService1 : DataService\n\n 1 In the InitializeService method, add the line:\n\nconfig.SetEntitySetAccessRule(\"*\", EntitySetRights.All);\n\nThe method should look like this\n\npublic static void InitializeService(IDataServiceConfiguration config)\n{\n // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.\n // Examples:\n // config.SetEntitySetAccessRule(\"MyEntityset\", EntitySetRights.AllRead);\n // config.SetServiceOperationAccessRule(\"MyServiceOperation\", ServiceOperationRights.All);\n\n config.SetEntitySetAccessRule(\"*\", EntitySetRights.All);\n}\n\n \n---+++ Step 4 - Compile and Run\nHit F5 to compile and run the service. Click OK when prompted to enable debugging. \nThe default browser will be launched showing a page like --\n\n \n- \n- \n Default \n- \n sparqlview \n \n \n \n\nThe service is now running. \n\nNote the address on which the service is made available. You will need to know this when \ncreating the app to consume the service. Look in the Address Bar of the browser. It will \nbe something like: http://localhost:1492/WebDataService1.svc/\n\n\n\n---++ Creating the Browser Application\n\n---+++ Step 1 - Create the Visual Studio Project\n\n 1 Open Visual Studio and create a new ASP.NET Web Application called \nRDFWebApp.\n%BR%%BR%%BR%%BR%\n 1 Create client side entities with datasvcutil.exe.\n 1 Open a command prompt.\n 1 Navigate to C:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5.\n 1 Generate the client classes using the following command:\n\ndatasvcutil.exe /uri:http://localhost:1492/WebDataService1.svc /out:DemoEntities.cs\n\nNote the address of the service. You may need to change the port number to match the one \nseen in the address at the end of Step 4 in Creating the Web Service. \n 1 Add the classes to RDFWebApp. \n 1 Right click RDFWebApp.\n 1 Choose to add an existing item and add \nc:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5\\DemoEntities.cs.\n 1 Add a reference to System.Data.Services.Client to the project.\n\n---+++ Step 2 - Display the contents of sparqlview as a table on the page\n\nTo display the RDF data on the web page, we create a table with a row for each item in sparqlview. \nWe then use each IRI from sparqlview to create a hyperlink. The hyperlinks are displayed in the \ntable cells. To do this, add the following block of code to the page_load \nmethod in Default.aspx.cs.\n\nDemoModel.DemoEntities svc = new DemoModel.DemoEntities(new Uri(\"http://localhost:1492/WebDataService1.svc\"));\n\nvar query = svc.sparqlview;\nTable iriTable = new Table();\nthis.Controls.Add(iriTable);\n\nforeach (DemoModel.sparqlview sv in query)\n{\n TableRow tRow = new TableRow();\n iriTable.Rows.Add(tRow);\n TableCell tCell = new TableCell();\n tRow.Cells.Add(tCell); \n HyperLink h = new HyperLink();\n h.Text = sv.s;\n h.NavigateUrl = sv.s;\n tCell.Controls.Add(h);\n}\n\nNote the address of the service in the first line. You may need to change the port number to \nmatch the one seen in the address at the end of Step 4 in Creating the Web Service.\n\nCompile and run RDFWebApp (ensuring that the service created above is \nstill running). This will launch a browser and display the IRIs from sparqlview as a list of \nhyperlinks. \n%BR%%BR%%BR%%BR%\n\nWith the \n[[http://s3.amazonaws.com/opldownload/uda/vad-packages/6.1/virtuoso/cartridges_dav.vad][Cartridges VAD package]] \ninstalled in Virtuoso, clicking on these links will take you to a description page of the \nreferenced resource. The description page is created using \n[[http://virtuoso.openlinksw.com/Whitepapers/html/vdld_html/VirtDeployingLinkedDataGuide_Glossary.html#mozTocId13075][description.vsp]].\n%BR%%BR%%BR%%BR%\n\n---++ Deploy With IIS\n\nWe have used the Visual Studio Development Server to create and test this simple Web Service. \nThis section describes how to deploy the service using IIS.\n\n---+++ Web Service\n\nTo deploy the service using IIS:\n 1 Open the RDFWebDemo project in Visual Studio, go to the \nProject menu and select RDFWebDemo Properties.\n 1 Select the Web tab and scroll down to the Servers section. Select \nUse local IIS Server. The project URL defaults to using localhost. \n 1 Click the Create Virtual Directory button then check that the Service works on localhost. \n 1 Build the project; then start without debugging (ctrl-F5). \n\nThe start page that you see when you test the service will look the same as before but the \naddress in the browser bar will be something like \nhttp://localhost/RDFWebDemo1/WebDataService1.svc/. You \ncan now access your service remotely using the hostname or IP address of your server.\n\nIf at this point you get an Access is denied error, 401.3, then you will need to \nadd the Internet Guest Account (IUSR_XXX where XXX is your computer \nname) to the users allowed to access the folder containing the RDFWebDemo project.\n \n---+++ Web Application\n\nYou will now need to modify RDFWebApp to access the service at the new address. \nAt the same time we will also change RDFWebApp so that it too is deployed using IIS \n 1 Open The RDFWebApp project in Visual Studio.\n 1 Go to the Project menu and select RDFWebApp Properties.\n 1 Select the Web tab and scroll down to the Servers section. Select Use \nlocal IIS Server. The project URL defaults to using localhost. \n 1 Click the Create Virtual Directory button. The web application will then run on \nthe local IIS.\n 1 To reference the web service running on IIS you will need to edit \nDefault.aspx.cs. Change\n\nDemoModel.DemoEntities svc = new DemoModel.DemoEntities(new Uri(\"http://localhost:1492/WebDataService1.svc\"));\n\nto\n\nDemoModel.DemoEntities svc = new DemoModel.DemoEntities(new Uri(\"http://localhost/RDFWebDemo/WebDataService1.svc/\"));\n\n 1 Build the project then start without debugging (ctrl-F5).\n\nThe web application is accessible on \nhttp://localhost/RDFWebApp/Default.aspx and can also be \naccessed using the hostname or IP address of your server, e.g., \nhttp://192.168.7.129/RDFWebApp/Default.aspx\n\n%BR%%BR%%BR%%BR%\n\n---++ Next Steps\nThis example showed you how to quickly create an ADO.NET Data Service that exposes RDF data in \nVirtuoso and how to create a basic Web application to consume that service. The next step is \nto create a Silverlight Application to consume the same service.\n\n * [[VirtSPASQLSilverLightApp][Creating a Silverlight Application to consume the service]]\n\n" . . . . . . . . "VirtSPASQLWebDataServiceApp" . . . . . . "2017-06-13T05:40:57Z" . . "2017-06-13T05:40:57Z" . . . "2017-06-13T05:40:57.386082"^^ .