【问题标题】:WCF Test Client fails to add service - Cannot obtain MetadataWCF 测试客户端无法添加服务 - 无法获取元数据
【发布时间】:2016-08-20 16:01:24
【问题描述】:

我看到有很多关于这个特定问题的问题。我花了一天半的时间尝试所有不同的建议。到目前为止,没有一个对我有用,我不知道下一步该做什么。所以我呼吁在这里找到的庞大知识库,希望有人能看到问题并帮助我。有一次,几年前,我让这一切都为我工作,几台电脑前。但是当我不得不更换一台新电脑时,我无法让它在当时或之后的任何时候工作,但能够解决它。现在我需要为当前的作业解决这个问题。

我有一个 SOAP WCF WebService 在我的本地机器上的 IIS(不是 IIS Express)中运行。

我创建了一个应用程序池。基本设置是具有集成管道模式的 .NET Framework v4.0.30319。高级设置将 Identity 设置为 ApplicationPoolIdentity。

我创建了一个网站(不使用默认网站。)

定义了两个绑定:

我们有一个客户和一个服务自签名证书,用于开发和 QA。我已将服务证书分配给 https 绑定。 Web 服务通过 net.tcp 与另一个 wcf 服务通信。

在基本设置中,我已经定义了 c:\inetpub\websitename 的物理路径。为了成功连接,使用测试设置...,我必须以特定用户身份连接,使用我的网络域用户 ID 和密码。我还没有找到解决这个问题的方法。

在高级设置中......应用程序池设置为我创建的应用程序池。物理路径是 c:\inetpub\wwwroot\websitename。启用的协议设置为 http,net.tcp。

我能够成功浏览到该网站。

这里是 web 服务的 web.config:

  <system.serviceModel>
<client>
  <endpoint address="net.tcp://10.100.13.28:8102/Acord/201307" behaviorConfiguration="NetTcpCertificatesBehavior" binding="netTcpBinding" bindingConfiguration="NetTcpCertificatesBinding" contract="AcordContract.IAcordService201307" name="AcordEndpoint">
    <identity>
      <certificateReference findValue="7da522dd75f3fca2687837b7b67e117a8700ec62" isChainIncluded="false" storeLocation="LocalMachine" x509FindType="FindByThumbprint" />
      <!--<dns value="localhost" />-->
    </identity>
  </endpoint>
  <endpoint address="net.tcp://qaschedapp:8002/IMS/201210" behaviorConfiguration="NetTcpCertificatesBehavior" binding="netTcpBinding" bindingConfiguration="NetTcpCertificatesBinding" contract="IdentityManagementContract.IIdentityManagementService201210" name="IMSEndpoint">
    <identity>
      <certificateReference findValue="7da522dd75f3fca2687837b7b67e117a8700ec62" isChainIncluded="false" storeLocation="LocalMachine" x509FindType="FindByThumbprint" />
    </identity>
  </endpoint>
</client>
<services>
  <service name="AcordWebService.AcordWebService" behaviorConfiguration="Visible">

    <endpoint address="" binding="basicHttpsBinding" contract="AcordWebService.IAcordWebService201307" bindingConfiguration="BasicHttpsBinding">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="https://10.100.13.28:51448/" />
      </baseAddresses>
    </host>
    <!--binding for clients outside the firewall calling from C# with WCF using certs -->
    <endpoint address="net.tcp://10.100.13.28:8122/AcordWebService.svc" binding="netTcpBinding" bindingConfiguration="NetTcpCertificatesBinding" name="NetTcpCertificatesEndpoint" contract="AcordWSContract.IAcordWSService201309">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="NetTcpCertificatesBehavior">
      <clientCredentials>
        <clientCertificate findValue="631f5a67a9a70bc78540bb809e73fd1dbd00bbeb" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" />
        <serviceCertificate>
          <authentication certificateValidationMode="None" />
        </serviceCertificate>
      </clientCredentials>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="Visible">
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" httpGetUrl=""/>
      <!-- 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"/>
      <serviceCredentials>
        <serviceCertificate findValue="7da522dd75f3fca2687837b7b67e117a8700ec62" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
        <clientCertificate>
          <certificate findValue="631f5a67a9a70bc78540bb809e73fd1dbd00bbeb" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>
        </clientCertificate>
      </serviceCredentials>
    </behavior>   
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpsBinding>
    <!--binding for clients within the firewall but calling the old style soap service-->
    <binding name="BasicHttpsBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </basicHttpsBinding>
  <netTcpBinding>
    <binding name="NetTcpCertificatesBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <!--<readerQuotas maxDepth="32" maxStringContentLength="65535" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />-->
      <!--<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />-->
      <security>
        <transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>
<protocolMapping>
  <add binding="wsHttpBinding" scheme="https" />
</protocolMapping>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

这是我在尝试向 WCF 测试客户端添加服务时收到的完整错误:

错误:无法从https://10.100.13.28:51448/AcordWebService.svc 获取元数据如果这是您有权访问的 Windows (R) Communication Foundation 服务,请检查您是否已在指定地址启用元数据发布。有关启用元数据发布的帮助,请参阅位于 http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange 错误 URI:https://10.100.13.28:51448/AcordWebService.svc 元数据包含无法解析的引用的 MSDN 文档:“https://10.100.13.28:51448/AcordWebService.svc”。无法为具有权限“10.100.13.28:51448”的 SSL/TLS 安全通道建立信任关系。基础连接已关闭:无法为 SSL/TLS 安全通道建立信任关系。根据验证程序,远程证书无效。HTTP GET 错误 URI:https://10.100.13.28:51448/AcordWebService.svc 下载“https://10.100.13.28:51448/AcordWebService.svc”时出错。基础连接已关闭:无法为 SSL/TLS 安全通道建立信任关系。根据验证程序,远程证书无效。

最后,填补信息中的几个漏洞:

如果我能够最终解决这个问题,我们将不胜感激。

提前致谢。

【问题讨论】:

    标签: web-services wcf testing client metadata


    【解决方案1】:

    这是我解决问题的方法:

    首先,我必须在我的 web.config 中打开日志记录:

      <system.serviceModel>
        <diagnostics>
          <messageLogging maxMessagesToLog="30000" logEntireMessage="true"
                  logMessagesAtServiceLevel="true"
                  logMalformedMessages="true"
                  logMessagesAtTransportLevel="true"
                  maxSizeOfMessageToLog="65535000">
          </messageLogging>
        </diagnostics>
      </system.serviceModel>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Verbose, ActivityTracing"
                  propagateActivity="true">
            <listeners>
              <add name="traceListener" />
            </listeners>
          </source>
        </sources>
        <sharedListeners>
          <add name="traceListener"
               type="System.Diagnostics.XmlWriterTraceListener"
               initializeData="c:\logs\Traces.svclog" />
        </sharedListeners>    
        <trace autoflush="true" />
      </system.diagnostics>
    

    然后检查生成的日志,我终于发现我的 Web 服务的构造函数尝试初始化 NLog 失败。最终,我发现 NLog 试图写入它没有权限的 EventLog。我按照here 的说明进行操作,只是我将权限授予 IIS AppPool 用户。这解决了我的问题。

    【讨论】:

      猜你喜欢
      • 2012-02-25
      • 1970-01-01
      • 2015-04-30
      • 2011-07-10
      • 1970-01-01
      • 2014-04-04
      • 2010-10-10
      • 2012-05-06
      • 1970-01-01
      相关资源
      最近更新 更多