Getting Started with Silverlight: Part III

Source: Internet
Author: User
Tags file system socket web services silverlight

Now that we have a basic layout and a few controls on it, let's start getting the data. Because we want to search for content on Twitter, we need to make full use of the Web services APIs they provide. Before proceeding, I would like to state that in this application, we will not build a database or other data source ourselves, but I would like to point out that there are many ways you can access data through Silverlight.

Data access Options

One of the misconceptions about accessing data in Silverlight is that they look for ado.net class libraries in Silverlight. Don't look for it, you can't find it. Remember that Silverlight is a client-side technology deployed on the Internet and you can't ask a browser plugin to access your database directly ... Unless you want to expose the database directly to the network. We all know that we must not do that.

So the more feasible way is to expose the data on the service layer. This is also the way Silverlight makes data communications. Here are some of the main means of access:

* Web service: SOAP, asp.net Web Services (ASMX), WCF services, POX, REST terminals

* Sockets: Network socket Communication (Network socket communication)

* Files: Accessing static content through Web requests

Sockets

Sockets may be the most advanced data access terminals. You need to have a socket host, and as I write this article, I also need to communicate through the specified port range. If this is acceptable to you, then this is a very effective and powerful way of accessing data. But if your app is open to the web, then I don't think this is the way to go mainstream. In my opinion, this approach is more commonly used in commercial applications. Here are some information on sockets:

* Software Development Kit (SDK) documentation

* Access to data via sockets (Dan Wahlin, MVP) – This is Silverlight2 information, but it doesn't affect your understanding of the concept

Before you decide to use it, you have to really understand your deployment plan and don't use it blindly.

File access

Silverlight can interact with local files or network files. For access to local files, although the application cannot directly access the file system, it is still possible to use OpenFileDialog and SaveFileDialog to allow the user to save the data stream locally for read-write operations.

In addition, you can use the standard HTTP commands in Silverlight to read and write plain text files and XML file information on the Web.

You may find yourself in this way to save the program settings data or to make simple data access.

Web Service (Web services)

This is the core of Silverlight's access to data-through the service layer. Silverlight supports accessing the underlying ASP.net Web services (ASMX) or WCF based services in VS, using our familiar way of adding service references, and will generate strongly typed proxy code for you.

In addition, you can access pox (Plain old XML) or rest based terminals through the standard HTTP protocol. Understanding the applications of these different service types is often the best way for developers to learn what data access is best for their projects.

The third. NET RIA Service is a new framework designed to make data access easier and easier. The linked video will introduce you to that topic. If you have a database that is put together with your Silverlight application, the. NET Ria Service is the best approach if you want the database to serve your Silverlight application.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.