2012-01-24 11 views
1

私はWCFサービスを設定して、SOAPとJsonの両方のエンドポイントを公開しようとしていました。しかし、そうすることで、私はエラーで私のMEXエンドポイントを壊れているように見える:WCF - サービスによって実装された契約のリストにIMetadataExchangeが見つかりませんでした

System.InvalidOperationException: The contract name 'IMetadataExchange' could not be found in the list of contracts implemented by the service TestService. Add a ServiceMetadataBehavior to the configuration file or to the ServiceHost directly to enable support for this contract.

<configuration> 
    <system.web> 
    <compilation debug="true"/> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name ="soapBinding"> 
      <security mode="None"/> 
     </binding> 
     </basicHttpBinding> 
     <webHttpBinding> 
     <binding name="webBinding"/> 
     </webHttpBinding> 
     <mexHttpBinding> 
     <binding name="mexBinding"/> 
     </mexHttpBinding> 
    </bindings> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="poxBehavior"> 
      <webHttp/> 
     </behavior> 
     <behavior name="jsonBehavior"> 
      <enableWebScript /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="defaultBehavior"> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <serviceMetadata httpGetEnabled="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service name="TVD_WCF_Services.TestService" behaviorConfiguration="defaultBehavior"> 
     <host> 
      <baseAddresses> 
      <!-- note, choose an available port--> 
      <add baseAddress="http://localhost:8732/Design_Time_Addresses/TVD_WCF_Services/TestService/" /> 
      </baseAddresses> 
     </host> 
     <endpoint address="soap" binding="basicHttpBinding" bindingConfiguration="soapBinding" contract="TVD_WCF_Services.ITestService" /> 
     <endpoint address="pox" binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="poxBehavior" contract="TVD_WCF_Services.ITestService" /> 
     <endpoint address="json" binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="jsonBehavior" contract="TVD_WCF_Services.ITestService" /> 
     <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="mexBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    </system.serviceModel> 

    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup> 
</configuration> 

私は設定に問題があると確信しているが、私の人生のために、私はそれが何であるかを動作することはできません。私はApp.config以外のものを変更していないことに注意してください。問題はこの中にあります。

私はこのサイトに関するこれ以外のさまざまな質問を見てきましたが、役に立たなかったのです。

そこにいるWCFの教祖は助けることができますか?私は契約属性が完全修飾型名を必要と信じて

<endpoint address="mex" binding="mexHttpBinding" 
      bindingConfiguration="mexBinding" 
      contract="System.ServiceModel.Description.IMetadataExchange" /> 

答えて

3

.NET 4.0フレームワークで単一のサービスにSOAP、Xml、およびJsonのエンドポイントをまとめて定義することに問題があります。

XmlまたはJsonエンドポイントを削除するだけで問題なく動作します。両方とも動作させたい場合は、問題なく動作する.NET 3.5に設定することができます。

私は両方のフレームワークのソースコードを見てきましたが、この問題を引き起こしている違いがあります。

linkは、私がバグとしてこれを提起した箇所に接続してください。 MSがそれを取得して、それ以降のリリースで問題を修正するよう投票を行ってください。

+0

ありがとうございますが、MEXエンドポイント以外はすべて削除しましたが、同じエラーが発生します – Simon

+0

mexエンドポイントとともに定義された少なくとも1つのエンドポイントが必要です。 – Rajesh

+0

なぜpoxBehaviourとdefaultBehaviourを削除したのか、そしてpoxエンドポイントがそれをしたのかどうか不明です。乾杯。 – Simon

0

はこれを試してみてください。

+0

おかげへの参照を持っていることを確認しますが、それはしませんでしたそれを行う:( – Simon

+0

私は同じ問題を抱えています、私は両方のソリューションを試してみましたが、MetadataExchangeインターフェイスの完全修飾名も含まれていませんでした – stephenbayer

+0

このWCFのすべての動作は非常に矛盾しています。 IMetadataExchangeを完全修飾すると、例外メッセージが変更されるo "契約名....サービス実装の契約リストに見つかりませんでした"。 IMetadataExchangeを使用している場合は、IMetadataExchangeも見つからないと表示されます。 –

0

シクスト

はあなたにapp.configを/ web.configファイルを持っているプロジェクトがSystem.ServiceModel

よろしく GregJF

関連する問題