0

我正在尝试使用核心服务脚本连接到 Tridion,这是我的代码:

public static SessionAwareCoreServiceClient Client;


Client = new SessionAwareCoreServiceClient("netTcp_2011");
Client.ClientCredentials.Windows.ClientCredential = new NetworkCredential(user, password);

web.Config 有以下内容:

<system.serviceModel>
    <!-- Default/example WCF settings for Core Service. These settings should be copied into the host application's configuration file. -->
    <bindings>
      <!-- Default Core Service binding settings are provided here. These can be used as a starting point for further customizations. -->
      <basicHttpBinding>
        <binding name="basicHttp" maxReceivedMessageSize="10485760">
          <readerQuotas maxStringContentLength="10485760" maxArrayLength="10485760"/>
          <security mode="TransportCredentialOnly">
            <!-- For LDAP or SSO authentication of transport credentials, use clientCredentialType="Basic" -->
            <transport clientCredentialType="Windows"/>
          </security>
        </binding>
        <binding name="streamDownload_basicHttp" maxReceivedMessageSize="209715200" transferMode="StreamedResponse" messageEncoding="Mtom" sendTimeout="00:15:00">
          <security mode="TransportCredentialOnly">
            <!-- For LDAP or SSO authentication of transport credentials, use clientCredentialType="Basic" -->
            <transport clientCredentialType="Windows"/>
          </security>
        </binding>
        <binding name="streamUpload_basicHttp" maxReceivedMessageSize="209715200" transferMode="StreamedRequest" messageEncoding="Mtom" receiveTimeout="00:15:00">
          <security mode="None"/>
        </binding>
      </basicHttpBinding>
      <netTcpBinding>
        <binding name="netTcp" transactionFlow="true" transactionProtocol="WSAtomicTransaction11" maxReceivedMessageSize="2147483647">
          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
        </binding>
        <binding name="streamDownload_netTcp" maxReceivedMessageSize="2147483647" transferMode="StreamedResponse" sendTimeout="00:20:00"/>
        <binding name="streamUpload_netTcp" maxReceivedMessageSize="2147483647" transferMode="StreamedRequest" receiveTimeout="00:20:00"/>
      </netTcpBinding>
    </bindings>
    <client>     
      <!--Dev 2013   -->
      <endpoint name="netTcp_2011" address="net.tcp://localhost:2660/CoreService/2011/netTcp" binding="netTcpBinding" bindingConfiguration="netTcp" contract="Tridion.ContentManager.CoreService.Client.ISessionAwareCoreService"/>
      <endpoint name="streamDownload_netTcp_2011" address="net.tcp://localhost:2660/CoreService/2011/streamDownload_netTcp" binding="netTcpBinding" bindingConfiguration="streamDownload_netTcp" contract="Tridion.ContentManager.CoreService.Client.IStreamDownload"/>
      <endpoint name="streamUpload_netTcp_2011" address="net.tcp://localhost:2660/CoreService/2011/streamUpload_netTcp" binding="netTcpBinding" bindingConfiguration="streamUpload_netTcp" contract="Tridion.ContentManager.CoreService.Client.IStreamUpload"/>
      <!--  -->

    </client>
  </system.serviceModel>

我仍然收到此错误:

Could not connect to net.tcp://localhost:2660/CoreService/2011/netTcp. The connection attempt lasted for a time span of 00:00:01.0520000. TCP error code 10061: No connection could be made because the target machine actively refused it localhost:2660.

注意: localhost 也可以是 CMS 实例的 IP。

任何人都可以帮忙吗?

4

2 回答 2

2

好的,所以随着时间的推移,我自学了,可以清楚地说错误target machine actively refused it localhost:2660清楚地表明该端口未开放供您使用。

因此,请确保执行以下两件事:

  1. 确保您已在 IIS 中允许 net.tcp
  2. windows防火墙打开2660端口?

    运行 anetstat -tan查看 2660 上是否有任何东西在运行,如果没有,则无法访问它。

此外,如果您正在从本地系统或其他服务器运行代码,以防万一netTcp不工作,请尝试使用wsHttpBasicHttp(假设您在服务器核心服务的 web.config 中有这些绑定)

于 2016-09-22T07:13:58.833 回答
1

核心服务作为 Windows 服务运行,而不是从 IIS 运行。打开 Windows 服务并确保 Tridion Content Manager 服务主机正在运行。

于 2015-06-30T11:22:56.600 回答