Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 错误:无法从http获取元数据……?wsdl_C#_Wcf_Ssl_Https_Metadata - Fatal编程技术网

C# 错误:无法从http获取元数据……?wsdl

C# 错误:无法从http获取元数据……?wsdl,c#,wcf,ssl,https,metadata,C#,Wcf,Ssl,Https,Metadata,我一直在使用自签名证书将http应用程序转换为https和ssl 出于某种原因,我必须在浏览器中转到localhost:来启动服务 一旦服务启动,我将在visual studio 2012 comman提示符中使用以下调用对其进行测试: svcutil.exe https://localhost:10201/?wsdl 然后它又回来了 Error: Cannot obtain Metadata from https://localhost:10201/?wsdl If this is a W

我一直在使用自签名证书将http应用程序转换为https和ssl

出于某种原因,我必须在浏览器中转到localhost:来启动服务

一旦服务启动,我将在visual studio 2012 comman提示符中使用以下调用对其进行测试:

svcutil.exe https://localhost:10201/?wsdl
然后它又回来了

Error: Cannot obtain Metadata from https://localhost:10201/?wsdl

If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.


WS-Metadata Exchange Error
    URI: https://localhost:10201/?wsdl

    Metadata contains a reference that cannot be resolved: 'https://localhost:10201/?wsdl'.

    Could not establish trust relationship for the SSL/TLS secure channel with authority 'localhost:10201'.

    The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

    The remote certificate is invalid according to the validation procedure.


HTTP GET Error
    URI: https://localhost:10201/?wsdl

    There was an error downloading 'https://localhost:10201/?wsdl'.

    The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

    The remote certificate is invalid according to the validation procedure.

If you would like more help, type "svcutil /?"
这是我成功的关键吗

我的配置如下所示:

<system.serviceModel>

    <!--SERVICES-->
    <services>
      <service name="DuplexService.DuplexService"
         behaviorConfiguration="sb">

        <endpoint
           address="basic"
           binding="customBinding"
           bindingConfiguration="customDuplexBinding"
           contract="DuplexService.Interface.IDuplexServiceContract">
        </endpoint>

        <endpoint
            address=""
            binding="webHttpBinding"
            behaviorConfiguration="webHttpEndpointBehavior"
            bindingConfiguration="webHttpsBinding"
            contract="Interface.IPolicyRetriever">
        </endpoint>

        <endpoint
            address="mex"
            binding="mexHttpsBinding"
            contract="IMetadataExchange">
        </endpoint>

        <host>
        <baseAddresses>
          <add baseAddress="https://localhost:10201" />
        </baseAddresses>
        </host>
      </service>


    </services>


    <!--BEHAVIOURS-->
    <behaviors>
    <!--Policy-->
      <endpointBehaviors>
        <!-- For Policy Service -->
        <behavior name="webHttpEndpointBehavior">
          <webHttp  />
        </behavior>
      </endpointBehaviors>


<!--behaviour for all of the enpoints -->
      <serviceBehaviors>
        <behavior name="sb">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://localhost:10201"/>
          <!-- 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="true"/>
          <!-- This will solve a bug that happens if too many items are sent at once from the gateway to the client -->
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          <serviceThrottling
          maxConcurrentCalls="200"
          maxConcurrentSessions="200"
          maxConcurrentInstances="200" />
        </behavior>
      </serviceBehaviors>
    </behaviors>



    <!-- BINDINGS-->
    <bindings>

    <webHttpBinding>
        <binding name="webHttpsBinding">
            <security mode="Transport">
                <transport clientCredentialType="None" />
            </security>
        </binding>
    </webHttpBinding>

      <customBinding>
        <binding name="customDuplexBinding">
          <pollingDuplex duplexMode="MultipleMessagesPerPoll"
               maxOutputDelay="00:00:01"
       serverPollTimeout="00:01:00"
       inactivityTimeout="02:00:00"
       maxPendingMessagesPerSession="2147483647"
       maxPendingSessions="2147483647" />
          <binaryMessageEncoding>
            <readerQuotas
              maxDepth="2147483647"
              maxStringContentLength="2147483647"
              maxArrayLength="2147483647"
              maxBytesPerRead="2147483647"
              maxNameTableCharCount="2147483647" />
          </binaryMessageEncoding>
          <httpsTransport
      maxBufferSize="2147483647"
      maxReceivedMessageSize="2147483647"
      transferMode="StreamedResponse" />
        </binding>
      </customBinding>



    </bindings>




    <!-- Register the binding extension from the SDK. -->
    <extensions>
      <bindingElementExtensions>
        <add name="pollingDuplex"
             type="System.ServiceModel.Configuration.PollingDuplexElement, System.ServiceModel.PollingDuplex" />
      </bindingElementExtensions>
    </extensions>
  </system.serviceModel>

我怎样才能摆脱它?让元数据正常工作,让GET正常工作?

我可以想出4种方法来处理这个问题

将自签名证书作为受信任的根身份验证安装。MMC->证书 使用浏览器导航到wsdl,单击证书错误,保存它,并直接生成wsdl。 将wsdl的url放在浏览器中,然后单击证书警告,以便可以看到实际的wsdl 将wsdl保存到您的计算机。在chrome中,您可以右键单击“另存为”。 在VisualStudio中 右键单击项目并选择添加服务引用 在地址框中,输入物理路径C:\directory。。。下载的wsdl。 一鼓作气 启动fiddler并告诉它解密https,这将安装证书,并为您提供忽略远程证书错误的选项。这里描述。 使用由受信任的根用户签名的证书。
我没有看到svcutil选项可以忽略证书错误。

我也遇到了同样的问题。对我来说,我注意到https正在使用另一个证书,该证书在到期日期方面是无效的。不知道为什么会这样。我更改了Https端口号和新的自签名证书。WCFtestClinet可以通过Https连接到服务器

没有帮助,但对其他人将来搜索答案会有帮助1和2不起作用,4应该等于1。3不适用于我,因为由于访问限制,我无法安装fiddler。还有别的办法吗?@Juergen认为1和2应该一直有效。我只是在2上扩展了方向,因为我觉得大多数人都不明白怎么做。当我有一个时刻至少我没有为我工作时,我也会扩展到1。我觉得应该也行,也许我做错了什么?我在服务器端用CN=[Servername]创建了一个自签名证书,并将其添加到客户端的受信任根CA中。还是一样的错误。我无法真正申请2,因为在我的浏览器IE中,我没有收到证书警告。在导航到service.svc或.wsdl文件时都没有。我尝试加载.wsdl并在其上应用svcutil,但返回另一个错误。在另一个线程中,我发现这可能不是完整/正确的wsdl文件,所以我将其删除。@KennethIto是的,我使用的是svcutil.exe,我知道使用SOAP已经过时,但我们正在将使用SOAP API的类库从.NET Framework转换为.NET Core,因此无法再使用Visual Studio SOAP web引用。我最终能够让它工作,只是在下载WSDL时遇到了困难。