WCF元数据包含无法解析的引用,错误转换为HTTPS

时间:2018-08-07 13:54:58

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

该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后出现此问题
这是我的 App.Config


         

  <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

2 个答案:

答案 0 :(得分:0)

尝试添加

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

system.serviceModel

答案 1 :(得分:0)

这是我解决自我的两个问题, 第一个连接字符串错误

"Data Source=testserver2\\maximizer

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

我没有时间去尝试修复Visual Studio。

通过任何方式

欢呼