【问题标题】:WCF Metadata contains a reference that cannot be resolved, error converting to HTTPSWCF 元数据包含无法解析的引用,转换为 HTTPS 时出错
【发布时间】:2018-08-07 13:54:58
【问题描述】:

我对此 WCF 网络服务有疑问。我试图让它在 HTTPS 中运行,在 HTTP 中运行正常。 我收到此错误:

https://localhost:8733/Design_Time_Addresses/WebServiceOppLink/Service1/mex Metadata contains a reference that cannot be resolved: 'https://localhost:8733/Design_Time_Addresses/WebServiceOppLink/Service1/mex'. An error occurred while making the HTTP request to https://localhost:8733/Design_Time_Addresses/WebServiceOppLink/Service1/mex. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server. The underlying connection was closed: An unexpected error occurred on a send. Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. An existing connection was forcibly closed by the remote hostHTTP GET Error URI: https://localhost:8733/Design_Time_Addresses/WebServiceOppLink/Service1/mex There was an error downloading 'https://localhost:8733/Design_Time_Addresses/WebServiceOppLink/Service1/mex'. The underlying connection was closed: An unexpected error occurred on a send. Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. An existing connection was forcibly closed by the remote host


将协议更改为 HTTPS 后出现此问题
这是我的 应用程序配置


  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" />

  </system.web>
  <connectionStrings>
    <add name="DatabaseConnection" connectionString="Data Source=testserver2\\maximizer;Initial Catalog=financial;Persist Security Info=True;User ID=sa;Password=loiranoia" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <!-- 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="secureHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>

      <service name="WebServiceOppLink.Service1" behaviorConfiguration="metadataBehavior" >
        <host>
          <baseAddresses>
            <add baseAddress = "https://localhost:8733/Design_Time_Addresses/WebServiceOppLink/Service1/" />
          </baseAddresses>
        </host>
        <!--
        <endpoint address="" 
        binding="wsHttpBinding" 
        contract="WebServiceOppLink.IService1">
         </endpoint>
        <endpoint address="mex" 
        binding="mexHttpBinding" 
        contract="IMetadataExchange"/>
        !-->
        <endpoint address=""
                    binding="basicHttpBinding"
                    bindingConfiguration="secureHttpBinding"
                    contract="WebServiceOppLink.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>

        <endpoint address="mex"
                  binding="mexHttpsBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="metadataBehavior">
          <useRequestHeadersForMetadataAddress>
            <defaultPorts>
              <!-- Use your own port numbers -->
              <add scheme="http" port="80" />
              <add scheme="https" port="443" />
            </defaultPorts>
          </useRequestHeadersForMetadataAddress>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />

        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>


看起来它试图将 HTTP MEX 用于 HTTPS URL。但这只是一个猜测.. 你们能帮我解决这个问题吗? 干杯 W

【问题讨论】:

  • 确切的错误是什么?
  • 我编辑时出现错误。

标签: c# visual-studio web-services wcf


【解决方案1】:

尝试添加

<protocolMapping>
    <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>

system.serviceModel

【讨论】:

【解决方案2】:

我自己解决了 2 个问题, 第一个连接字符串错误

"Data Source=testserver2\\maximizer

它有 2 个“\” 其次,Visual Studio 不能信任自证书但在具有有效证书的计算机上运行。

我没有时间浪费在修复 Visual Studio 上。

感谢任何方式

干杯

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-08
    相关资源
    最近更新 更多