In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is a WCF REST service". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what a WCF REST service is.
.net Framework 3.5 introduces REST-style Windows Communication Foundation (WCF) services. In addition to developing and hosting RESTful services, there are a variety of options to consume these services. WCF provides REST support through the "web" binding and the web programming model that allows RESTful services to be published. The RESTful service returns a normal XML,JSON code, or syndication feed. There are a lot of resources on the web about how to write such services, but how to consume them in .NET Framework
WCF REST services say very little.
In Simon Evan's article "consuming Services with Silverlight 2.0," he points out that auto-generating proxies like those in SOAP Web Service are not currently supported: consuming other services (such as REST) is a bit difficult, and what does surprise us is that proxies used by ASP.net AJAX (through WebHttpBinding) cannot be automatically generated yet. You have to manually build a URI string and use the WebClient class when making a HTTP GET request (REST); for other HTTP verbs, use the HttpWebRequest class. If the service uses JSON encoding, either of these two methods are available for parsing the response: using WCF's DataContractJSONSerializer (conceptually similar to XmlSerializer), or using LinqToJSON...
Json.NET (LinqToJSON) can be found on the Codeplex website. As part of .NET Framework 3.5, LINQ to XML can easily parse and consume XML data. Pedram Rezaei explains how to develop a consumer for "interest list operations from Flickr". At first he adopted what Simon Evan called a three-step approach:
◆ makes the HTTP request and includes all parameter groups as part of URI
◆ gets the response in XML format
◆ either parses it or deserializes it into an object
He adopts a "WCF approach", and the WCF REST service consists of the following steps:
◆ defines a ServiceContract that represents a service provider.
The ◆ UriTemplate contains all the necessary parameters, which are exactly the same as the parameter list of their corresponding interface methods. The signature of this method also defines a CLR return type that deserializes the XML content from the service response. This method must be annotated with either the WebGet or WebInvoke attribute; and in order to match the XML,ServiceContract returned by the service as much as possible, it must be configured to use XmlSerializerFormat instead of DataContractSerializer format.
◆ configures client endpoints to use "webHttpBinding".
◆ defines XML serializable types for return values and parameters. Create a client agent by either instantiating ChannelFactory directly or inheriting it by ClientBase.
Even if this is a viable approach, Pedram criticizes that we do not use the unified programming model provided by WCF, and that URL is created through string concatenation. The response is also manually deserialized into an object. With WCF and WebHttpBinding, we can automate most of our work.
For details, please read Pedram's article. Mihailo Lalevic uses the same approach to develop a consumer for eBay API and provides a WPF sample application (source code) as an attachment to his article.
Thank you for your reading, the above is the content of "what is WCF REST service", after the study of this article, I believe you have a deeper understanding of what WCF REST service is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.