Benutzer:MovGP0/WCF/Metadata Exchange
< Benutzer:MovGP0 | WCF
MovGP0 | Über mich | Hilfen | Artikel | Weblinks | Literatur | Zitate | Notizen | Programmierung | MSCert | Physik |
Metadata Exchange[Bearbeiten | Quelltext bearbeiten]
Enable MEX Declaratively[Bearbeiten | Quelltext bearbeiten]<system.serviceModel>
<services>
<service name="MyService" behaviorConfiguration="mex">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mex">
<serviceMetadata httpGetEnabled="true"
httpGetUrl="MyMexAddress" <!-- optional -->
/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Enable MEX Imperatively[Bearbeiten | Quelltext bearbeiten]using(var host = new ServiceHost(typeof(MyService)))
{
var metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
if(metadataBehavior == null)
{
Debug.Assert(host.BaseAddresses.Any(baseAddress => baseAddress.Uri.Scheme == "http"));
var newMetadataBehavior = new ServiceMetadataBehavior();
newMetadataBehavior.HttpGetEnabled = true;
host.Description.Behaviors.Add(newMetadataBehavior);
}
// ...
host.Open();
// ...
}
|