Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is WCF metadata

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is WCF metadata". The content of the explanation 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 WCF metadata is.

WCF after a long period of development, more and more people use it, its function is also powerful, in my experience to deal with WCF metadata in programming. The application needs to get the metadata of the service endpoint to see if there is a contract that at least one endpoint supports the request. For example, if the metadata exchange endpoint is service-supported or based on the HTTP-GET protocol, then metadata is available in this endpoint. When we use the HTTP-GET protocol, the address of the metadata exchange is the HTTP-GET address (usually, the base address of the service is suffixed with? wsdl).

Types that support WCF metadata processing

Public enum MetadataExchangeClientMode {MetadataExchange, HttpGet} class MetadataSet:... {...} public class ServiceEndpointCollection: Collection {...} public class MetadataExchangeClient {public MetadataExchangeClient (); public MetadataExchangeClient (Binding mexBinding); public MetadataSet GetMetadata (Uri address,MetadataExchangeClientMode mode); / / more members} public abstract class MetadataImporter {public abstract ServiceEndpointCollection ImportAllEndpoints (); / / more members} public class WsdlImporter: MetadataImporter {public WsdlImporter (MetadataSet metadata) / / more members} public class ServiceEndpoint {public EndpointAddress Address {get;set;} public Binding Binding {get;set;} public ContractDescription Contract {get;} / / more members} public class ContractDescription {public string Name {get;set;} public string Namespace {get;set;} / / more members}

MetadataExchangeClient can use the binding associated with the WCF metadata exchange, which is saved in the application's configuration file. We can also pass the initialized binding instance to the constructor of MetadataExchange-Client. The passed binding instance contains some custom values, such as capacity. If the metadata returned exceeds the default received message size, the capacity value can be set in order to receive a larger message.

The GetMetadata () method of MetadataExchangeClient receives an instance of the endpoint address, which encapsulates the metadata exchange address and an enumerated value, specifying how to access it. The metadata returned by the method is placed in an MetadataSet instance. Instead of directly manipulating the MetadataSet type, we create a subclass instance of the MetadataImporter class, such as WsdlImporter, pass the original metadata to its constructor, and then call the ImportAllEndpoints () method to get a collection of all endpoints found in the metadata. Endpoints are represented as ServiceEndpoint types.

Thank you for your reading, the above is the content of "what is WCF metadata", after the study of this article, I believe you have a deeper understanding of what WCF metadata 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report