2010-08-06 50 views

回答

0

該框架將負責爲您執行。

但是,您必須創建一個啓用此操作的服務行爲。

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 

     <behaviors> 
      <serviceBehaviors> 
       <!-- behavior that enables metadata exchanges --> 
       <behavior name="mexGet"> 
        <serviceMetadata httpGetEnabled="true"/> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 
     <services> 
      <!-- assign the custom behavior here --> 
      <service name="MyNamespace.MyImplementation" 
        behaviorConfiguration="mexGet"> 
       <host> 
        <baseAddresses> 
         <add baseAddress="http://localhost:3849"/> 
        </baseAddresses> 
       </host> 
       <endpoint 
        address="MyService" 
        binding="wsHttpBinding" 
        contract="MyNamespace.MyServiceInterface" 
        > 

       </endpoint> 

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

       </endpoint> 
      </service> 
     </services> 
    </system.serviceModel> 
</configuration> 
0

沒有,只是補充暴露IMetadataExchange接口的端點。你不必執行任何操作。

0

無需實現'IMetadataExchange'。只需添加端點:

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

一個重要的事情,你必須聲明serviceMetadata,或者你IMetadataExchange不會被發現:

<behaviors> 
    <serviceBehaviors> 
     <behavior> 
      <serviceMetadata /> 
     </behavior> 
    </serviceBehaviors> 
</behaviors> 
相關問題