简体   繁体   中英

svc-less wcf service and metadata

I've tried to create svc-less wcf service. Service works, but no metadata are genereted. How can I return service metadata back?

Have you added a meta data endpoint to your service generation in the code?

 ServiceMetadataBehavior  smb = new ServiceMetadataBehavior();

    smb.HttpGetEnabled = true;

    smb.HttpGetUrl = new Uri(EndPointAddress);

    Host.Description.Behaviors.Add(smb);

Or using config file:

  <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="yourServiceName" 
               behaviorConfiguration="yourBehavior">
        <host>
          <baseAddresses>
            <add baseAddress = "yourBaseAddress" />
          </baseAddresses>
        </host>

        <endpoint address ="..." 
                  binding="httpBinding" 
                  contract="..." />

        <endpoint address="mex" 
                  binding="mexHttpBinding" 
                  contract="IMetadataExchange" />

      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="yourBehavior">
          <serviceMetadata httpGetEnabled="True"/>        
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

这里找到解决方案

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM