As some of you may already have figured out, there have been a few breaking chnages in WCF's RC1 OM which is currently being distributed with the June CTP of .NET Fx 3.0.
One point of confusion:
Metadata publishing is no longer enabled by default for WCF services. You must now explicitly configure metadata endpoints for your service by adding the ServiceMetadataBehavior (from System.ServiceModel.Description namespace) to your service and adding a IMetadataExchange-based endpoint using the standard mechanisms for adding endpoints to a WCF service.
The metadataPublishing behavior configuration section has been renamed to serviceMetadata accordingly. Also, the enableGetWsdl configuration attribute has been split into two attributes: httpGetEnabled and httpsGetEnabled. Likewise, the metadataLocation attribute has been renamed to externalMetadataLocation. OK, so much for the theory.
So here is a complete sample in config - this enables both WSDL and MEX metadata:
<configuration>
<system.serviceModel>
<services>
<service name="Service.TecTvService"
behaviorConfiguration="metadataBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:7777/tectv"/>
</baseAddresses>
</host>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
/>
<endpoint
address="net.tcp://localhost:1234/tectv"
binding="netTcpBinding" bindingConfiguration="unsecureTcp"
contract="Contracts.ITecTv"
/>
<endpoint
address="http://localhost:7777/tectv/http"
binding="basicHttpBinding"
contract="Contracts.ITecTv"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Not quite. Adding serviceMetadata / alone, without any endpoints, enables HTTP/GET ?wsdl support at the baseaddresses specified that support HTTP. This is because httpGetEnabled is true by default. Adding serviceMetadata / AND adding an IMetadataEndpoint will get you WS-MetadataExchange support at that endpoint address. Do let me know if you don't see that behavior. Oh, and remember that because svcutil tries both http/get and WS-MEX, often it's difficult to know which one was the one that worked. ;-) Cheers, Ralph
Posted by: ralph | 07/07/2006 at 05:07 AM
There is nothing wrong with your and my statements, right? It all works as explained by the two of us. Of course, your comment makes the whole story more complete :)
Posted by: Christian Weyer | 07/07/2006 at 01:25 PM
can externalMetadataLocation be used to sepcify some external metadata other than the wsdl of the service?? is there anything that can be used to access some other metadata, e.g., the business information of the service provider??
Posted by: zille | 10/10/2006 at 04:43 PM
Yes, you can point to a URL with the wanted metadata if you are webhosted. If you are self-hosted then you would need to point to a webhosted metadata URL or just extend ServiceHost. I have such a sample here if you need it.
Posted by: Christian Weyer | 10/18/2006 at 11:09 AM