【问题标题】:WCF Bad Request. Metadata contains a reference that cannot be resolvedWCF 错误请求。元数据包含无法解析的引用
【发布时间】:2018-05-01 22:35:06
【问题描述】:

我在 WCF 服务中重命名了服务合同文件,现在尝试添加或更新服务引用时出现错误:

下载“http://localhost:8733/Design_Time_Addresses/MessengerService/MessengerService/mex/$metadata”时出错。 请求失败,HTTP 状态为 400:错误请求。 元数据包含无法解析的引用:“http://localhost:8733/Design_Time_Addresses/MessengerService/MessengerService/mex”。 元数据包含无法解析的引用:“http://localhost:8733/Design_Time_Addresses/MessengerService/MessengerService/mex”。 如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。

服务部署在 WcfSvcHost 中。 我的App.config

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

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="MessengerService.ServiceLogic.MessengerService">
        <endpoint address="" binding="wsDualHttpBinding" contract="MessengerService.Contracts.ServiceContracts.IMessengerService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/MessengerService/MessengerService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

如何解决?

【问题讨论】:

    标签: c# wcf wcf-binding


    【解决方案1】:

    这太不可思议了。所以,如果我在回调合约中编写这段代码:

    [OperationContract(IsOneWay = true)]
    void MakePulse();
    

    这很正常。但如果我这样写:

    [OperationContract(IsOneWay = true)]
    void Pulse();
    

    这绝对是错误的。

    【讨论】:

    • 你改变了其他东西。这不可能是真的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多