WCF测试客户端无法添加服务 - 无法获取元数据

时间:2016-04-26 17:10:36

标签: web-services wcf testing client metadata

我看到有关这个特殊问题的问题很多。我花了一天半时间尝试所有不同的建议。到目前为止,没有人为我工作,我不知道下一步该做什么。因此,我对这里发现的庞大知识基础有吸引力,希望有人能够看到问题并帮助我。在几年前的某个时候,我曾经在几台PC之前为我工作过。但是当我不得不改用一台新PC时,我无法让它在任何时候都能正常工作,但是能够解决它。现在我需要为当前的任务解决这个问题。

我在本地计算机上的IIS(不是IIS Express)中运行了SOAP WCF WebService。

我创建了一个App Pool。基本设置是具有集成管道模式的.NET Framework v4.0.30319。高级设置将标识设置为ApplicationPoolIdentity。

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

定义了两个绑定: Bindings

我们有一个客户端和一个服务自签名证书,我们用于开发和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上的MSDN文档:https://10.100.13.28:51448/AcordWebService.svc元数据包含无法解析的引用:&#39; https://10.100.13.28:51448/AcordWebService.svc&#39;。无法与具有权限的SSL / TLS安全通道建立信任关系&#;; 10.100.13.28:51448&#39;。底层连接已关闭:无法为SSL / TLS安全通道建立信任关系。根据验证程序,远程证书无效.HTTP GET错误URI:https://10.100.13.28:51448/AcordWebService.svc下载&#39; https://10.100.13.28:51448/AcordWebService.svc&#39;时出错。底层连接已关闭:无法为SSL / TLS安全通道建立信任关系。根据验证程序,远程证书无效。

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

Windows Features

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

提前致谢。

1 个答案:

答案 0 :(得分:1)

以下是我解决问题的方法:

首先,我必须打开登录web.config:

textView.textContainerInset = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8);

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