Querying Windows logs using the OData protocol

Source: Internet
Author: User
Tags database join json odbc ole reflection web services

OData Open Data Protocol is a Microsoft-Gdata Open Data protocol for Google, designed to promote the standardization of Web application database formats, and Microsoft defines OData as a protocol based on HTTP, AtomPub, and JSON to enhance data compatibility between various Web applications. To provide information access to a variety of applications, services, and data stores. Also, Microsoft has officially launched the OData SDK, which includes support for. NET, Java, PHP, Palm WebOS, and IPhone. where the. Net OData client is authorized for open source based on Apache. Microsoft has a variety of products already supported OData including SharePoint Server, Excel, Dynamics and so on.

Microsoft's first generation Data interchange protocol, called ODBC (Open database join Open DB connectivity), is still visible in Windows and Linux native program development to provide a unified API for data interaction between applications under the operating system, is a functional type. After the Microsoft launched its second generation: OLE DB, which brings the OOP style interaction API and the possibility of data interaction across the network (through DCOM), the implementation of the OLE DB Standard is a set of C + + API functions, like the ODBC API in ODBC standards, and, unlike, OLE DB API is COM compliant, object-based (the ODBC API is a simple C API). Using the OLE DB APIs, you can write applications that have access to any data source that conforms to OLE DB standards, or you can write query handlers for a particular data store (query Processor) and the cursor engine (Cursor Engine), so OLE DB The standard is actually a protocol (Application-level Protocol) that prescribes an application layer between the data consumer and provider. In the era of cloud computing, Web apps are already mainstream, and programs are primarily used to express requirements through HTTP requests, with HTTP response to get results, and ODBC and OLE DB are no longer available. Microsoft then developed its third-generation data-interchange protocol: The OData Open Data protocol.

In the world of SOA, one of the most important concepts is the contract (contract). In the cloud computing world, the most important concept of communication is also the contract. XML has a powerful ability to describe data, and the atom format and atompub are all built on XML, and have become the norm, driven by Google and Microsoft. However, there is a fundamental lack of real data interaction protocols such as ATOM/ATOMPUB and odbc/oledb: lack of specific descriptions of data types and reduced interaction performance. Lack of control over data queries, such as returning a specific set of data, or paging capability, etc. Microsoft based on the EDM model released: OData, here you can also see the Entity Framework for nhibernate such ORM tools different strategic considerations.

At the PDC conference, Microsoft announced a Community Technology Preview (CTP) code-named "Dallas", built with Windows Azure and SQL Azure, to enable developers and information workers to use high-quality Third-party data sets and content on any platform. "Dallas" can also be stored through the use of Microsoft technology Self-Service Business Intelligence and analysis of the data set. The Data interchange protocol used by Dallas is OData.

In Microsoft's solution, WCF is used to handle communication between all programs, and for data communication, WCF Data Services is naturally the best choice. First, WCF Data Services is a WCF service, so you can use all of the existing WCF knowledge. Second, WCF Data Services has implemented the OData topology, so you can focus on the presentation of your data format in your program, rather than atompub/json the data formats that are actually passed on the network. Again, WCF Data Services is committed to data transfer, not to the datastore. Your data can be stored in any location: Local database, Cloud database, external Web Services,xml file, and so on. No matter how the data comes, you can publish/use them in the same way.

Below we use the WCF Data service to publish the server's Windows application log out. Our applications can write logs directly in Windows logs, and then use the WCF Data service to easily expose the logs to other users who need them. The WCF Data Service uses the Entity Framework by default, using the Entity Framework to see the article WCF Data Service QuickStart, and a reflection Provider, can support read-only data services, this example is to demonstrate the use of reflection Provider, the data refer to msdn:http://msdn.microsoft.com/en-us/library/dd723653 (vs.100). ASPX, you can also customize the implementation of a provider, see the article Custom Data Service Providers.

First, the entity that defines a Windows log, similar to the datacontract of WCF, uses the mapping of the EDM:

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Data.Services.Common;
Namespace Reflectiondataservicedemo
{
[Entitypropertymappingattribute ("Source",
Syndicationitemproperty.title,
Syndicationtextcontentkind.plaintext, True)]
[Entitypropertymapping ("message"),
Syndicationitemproperty.summary,
Syndicationtextcontentkind.plaintext, True)]
[Entitypropertymapping ("timegenerated",
Syndicationitemproperty.updated,
Syndicationtextcontentkind.plaintext, True)]
[Dataservicekey ("EventID")]
public class LogEntry
{
Public long EventID
{
Get
Set
}
public string Category
{
Get
Set
}
public string Message
{
Get
Set
}
Public DateTime timegenerated
{
Get
Set
}
public string Source
{
Get
Set
}
}
}

Related Article

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.