简体   繁体   English

错误:无法从http ...?wsdl获取元数据

[英]Error: Cannot obtain Metadata from http …?wsdl

I have been in the process of converting a http application to https and ssl with a self signed certificate. 我一直在使用自签名证书将http应用程序转换为https和ssl。

for some reason i have to go in the browser to localhost:##### to start the service. 出于某种原因,我必须在浏览器中访问localhost:#####以启动该服务。

Once the service is started, i test it with the following call in the visual studio 2012 comman prompt: 一旦服务启动,我在visual studio 2012 comman提示符中使用以下调用进行测试:

svcutil.exe https://localhost:10201/?wsdl

and it comes back with 它回来了

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 /?"

Is this detremental to my sucess with HTTPS? 这对我使用HTTPS的成功是否有用?

My config looks as such: 我的配置看起来像这样:

<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>

How can i get rid of it? 我怎么能摆脱它? and make the metadata work and the GET work? 并使元数据工作和GET工作?

I can think of 4 ways to deal with this. 我可以想出4种方法来解决这个问题。

  1. Install the self signed cert as a trusted root auth. 将自签名证书安装为受信任的root身份验证。 MMC -> Certificates MMC - >证书
  2. Use a browser to navigate to the wsdl (click past the cert error), save it off, and generate off the wsdl directly. 使用浏览器导航到wsdl(单击过去的cert错误),将其保存,然后直接生成wsdl。
    • Put the url of the wsdl in your browser and click past the certificate warning so that you can see the actual wsdl 将wsdl的url放在浏览器中,然后单击证书警告,以便可以看到实际的wsdl
    • Save the wsdl to your computer. 将wsdl保存到您的计算机。 In chrome you can right click, save as. 在chrome中,您可以右键单击,另存为。
    • In Visual Studio 在Visual Studio中
      • Right click on the project and select "Add Service Reference" 右键单击该项目,然后选择“添加服务引用”
      • In the Address box, enter the physical path (C:\\directory...) of the downloaded wsdl. 在“地址”框中,输入下载的wsdl的物理路径(C:\\ directory ...)。
      • Hit Go 打Go
  3. Fire up fiddler and tell it to decrypt https which will install a cert and give you an option to ignore remote cert errors. 启动提琴手并告诉它解密https,这将安装证书并为您提供忽略远程证书错误的选项。 Described here. 这里描述。 http://proq.blogspot.com/2012/02/svcutil-and-https.html http://proq.blogspot.com/2012/02/svcutil-and-https.html
  4. Use a cert signed by a trusted root. 使用由受信任的根签名的证书。

I didn't see a svcutil option to ignore cert errors. 我没有看到svcutil选项来忽略cert错误。

I had the same issue. 我遇到过同样的问题。 For me I noticed that the https is using another Certificate which was invalid in terms of expiration date. 对我来说,我注意到https正在使用另一个证书,该证书在到期日期方面无效。 Not sure why it happened. 不知道为什么会这样。 I changed the Https port number and a new self signed cert. 我更改了Https端口号和一个新的自签名证书。 WCFtestClinet could connect to the server via HTTPS! WCFtestClinet可以通过HTTPS连接到服务器!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM