私は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" />
:
ありがとうございますが、MEXエンドポイント以外はすべて削除しましたが、同じエラーが発生します – Simon
mexエンドポイントとともに定義された少なくとも1つのエンドポイントが必要です。 – Rajesh
なぜpoxBehaviourとdefaultBehaviourを削除したのか、そしてpoxエンドポイントがそれをしたのかどうか不明です。乾杯。 – Simon