1.http-get WCF Mode
Provide metadata by means of HTTP
1.1. How to configure Files
<System.ServiceModel> <Services> <Servicename= "MyService"behaviorconfiguration= "Mexget"> <Host> <baseaddresses> <Addbaseaddress= "Http://localhost:8000/"/> </baseaddresses> </Host> ... </Service> <Servicename= "Myotherservice"behaviorconfiguration= "Mexget"> <Host> <baseaddresses> <Addbaseaddress= "http://localhost:8001/"/> </baseaddresses> </Host> ... </Service> </Services> <Behaviors> <servicebehaviors> <Behaviorname= "Mexget"> <Servicemetadatahttpgetenabled= "true"/> </Behavior> </servicebehaviors> </Behaviors></System.ServiceModel>
In general, the base site of HTTP can access metadata, or you can specify a different address:
<= "Mexget"> <= "true" = "mymexaddress"/></behavior>
1.2. Code mode
ServiceHost host =NewServiceHost (typeof(MyService)); ServiceMetadataBehavior Metadatabehavior;metadatabehavior= host. Description.behaviors.find<servicemetadatabehavior>();if(Metadatabehavior = =NULL) {Debug.Assert (Baseaddresses.any (baseaddress=>baseaddress.uri.scheme = ="http")); Metadatabehavior=NewServiceMetadataBehavior (); metadatabehavior.httpgetenabled=true; host. DESCRIPTION.BEHAVIORS.ADD (Metadatabehavior);} Host. Open ();
2.Metadata Exchange Endpoint
Platform-independent metadata exchange that supports multiple protocols
<Services> <Servicename= "MyService"behaviorconfiguration= "MEX"> <Host> <baseaddresses> <Addbaseaddress= "net.tcp://localhost:8001/"/> <Addbaseaddress= "net.pipe://localhost/"/> </baseaddresses> </Host> <EndpointAddress= "MEX"binding= "Mextcpbinding"Contract= "IMetadataExchange"/> <EndpointAddress= "MEX"binding= "Mexnamedpipebinding"Contract= "IMetadataExchange"/> <EndpointAddress= "Http://localhost:8000/MEX"binding= "mexHttpBinding"Contract= "IMetadataExchange"/> ... </Service></Services><Behaviors> <servicebehaviors> <Behaviorname= "MEX"> <Servicemetadata/> </Behavior> </servicebehaviors></Behaviors>
[Programming WCF Services] Chapter 1. WCF Essentials-metadata Exchange