17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5: <strong>FILESTREAM</strong> with ASP.NET and SilverlightThis code will run as is, but we have not yet enabled remote access to the DataAccesscomponent. However, at this time, you may want to run and test the web application toensure that it returns the image as expected, even though we do not yet have a way tosplit the data access layer from the web application.Adding remote calling capabilityIf we want to truly separate the web application from the data access layer, we musthave a way to call the methods in the data access class ItemData remotely. WindowsCommunication Foundation (WCF) is one .NET technology that allows inter-processand inter-machine communication. WCF was introduced with .NET FrameworkVersion 3 and has seen upgrades in more recent releases. An older technology forcalling remote code is called .NET Remoting. Even though the .NET Framework stillfully supports remoting, WCF is generally recommended. WCF services are easier toimplement because less "plumbing" code is required. A thorough discussion <strong>of</strong> theconcepts <strong>of</strong> WCF is beyond the scope <strong>of</strong> this book. However, the lab should be easy t<strong>of</strong>ollow with a basic understanding <strong>of</strong> the "ABCs" <strong>of</strong> WCF: Address + Binding + Contract =Service, as provided by this MSDN article: http://brurl.com/fs6.To add remote calling capability to our application, we will first create a componentthat will contain the definition <strong>of</strong> our WCF service contract. <strong>The</strong>n, we create a consoleapplication to host the data access component as a WCF service. Finally, we will modifythe web application to call the data access component running in the console host.Creating and implementing the service interfaceIn Solution Explorer, right-click the solution node and select Add, New Project…. Inthe Add New Project dialog box, select Class Library and name it ServiceInterfaces.Add a reference to the System.ServiceModel assembly and DataAccess project to thenew project. Remove the default Class1.cs file and add a new interface (right-click211

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!