2012-11-15 54 views
6

我一直在使用自签名证书将http应用程序转换为https和ssl。错误:无法从http获取元数据......?wsdl

由于某些原因,我必须在浏览器中使用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 /?" 

回来这是detremental我sucess与HTTPS?

我的配置看起来这样:

<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工作?

回答

10

我可以想出4种方法来解决这个问题。

  1. 将自签名证书安装为受信任的根认证。 MMC - >证书
  2. 使用浏览器导航到wsdl(单击通过证书错误),将其保存并直接生成wsdl。
    • 将wsdl的URL放入浏览器中,然后单击过去的证书警告,以便您可以看到实际的wsdl将wsdl保存到您的计算机。在Chrome中,您可以右键单击,另存为。
    • 在Visual Studio
      • 右键单击该项目并选择“添加服务引用”
      • 在地址框中,输入物理路径:下载的WSDL的(C \目录...)。
      • 击去
  3. 火了小提琴手,并告诉它进行解密,这将安装一个证书,并给你一个选择忽略远程证书错误HTTPS。在这里描述。 http://proq.blogspot.com/2012/02/svcutil-and-https.html
  4. 使用受信任根签名的证书。

我没有看到svcutil选项忽略证书错误。

+0

没有帮助,但将有助于其他人在未来寻找答案 –

+1

选项3工作的一种享受!选项3同上 –

+0

! – rhoeting

0

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

相关问题