2

I'm trying to connect to the Core Service and retrieve a Component to check its existence.

I created a console application to call the client. In my App.config file, I added the binding and endpoint information as below. When I added a basicHttp binding, the app executed normally but no correct result. It seems that protocol is different from that used in the CMS. So I converted the binding to wsHttpBinding. But a NullReference error came out one by one.

<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="EndPoint" value="CoreService"/>
<add key="Username" value="USERNAME"/>
<add key="Password" value="PASSWORD"/>
</appSettings>
<system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="CoreService_wsHttpBinding" transactionFlow="true" maxReceivedMessageSize="10485760">
      <readerQuotas maxStringContentLength="10485760" maxArrayLength="10485760" />
      <!-- For HTTPS, use mode="TransportWithMessageCredential" -->
      <security mode="Message">
        <message clientCredentialType="Windows" />
      </security>
   </binding>
  </wsHttpBinding>
 </bindings>
<client>
<endpoint name="CoreService"      address="http://localhost/webservices/CoreService201501.svc/wsHttp" binding="wsHttpBinding" bindingConfiguration="CoreService_wsHttpBinding" contract="Tridion.ContentManager.CoreService.Client.ISessionAwareCoreService">
     <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
</client>
</system.serviceModel>
</configuration>  

Could anyone tell me that which config file should I refer to when I config the App.config of my application.(web.config of WebRoot or the Tridion.ContentManager.CoreService.Client.dll.config ?)

I'm a tiro in this area.
Any advice would be highly appreciated.
Thanks in advance.

  • When I use a basicHttpbinding and endpoint to create a client, it worked, but the protocolException happened. When I changed to a wsHttpBinding and endpoint to create a client, it failed.(The client I created is null.) – Heimei Nov 2 '16 at 8:36
  • 2
    Have you seen this: github.com/TridionPractice/tridion-practice/wiki/… – Dominic Cronin Nov 2 '16 at 8:56
  • Yes. I copied the binding & endpoint information from coreservice.client.dll.config. When I use basicHttp, it came out a System.ServiceModel.ProtocolException. If changed to wsHttp, it came out a communicationobjectfaultedexception. – Heimei Nov 4 '16 at 1:53
1

I am using following stuff for non-AD account. Its working fine.

following setting in my app.config

<client>
      <endpoint address="http://myend/webservices/CoreService201501.svc/wsHttp"
          binding="wsHttpBinding" bindingConfiguration="wsHttp" contract="Tridion.ContentManager.CoreService.Client.ISessionAwareCoreService"
          name="wsHttp">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>

Following to create instance of CoreService name SessionAwareCoreServiceClient("wsHttp"); this name matches with endpoint name in config

 public static Client GetClientInstance()
        {

            if (_instance == null)
            {
                _instance = new SessionAwareCoreServiceClient("wsHttp");

                var userName = ConfigurationManager.AppSettings["CoreServiceUserName"];
                var domain = ConfigurationManager.AppSettings["CoreServiceDomain"];
                var password = ConfigurationManager.AppSettings["CoreServicePassword"];

                NetworkCredential creds = new NetworkCredential(userName, password, domain);
                                   _instance.CoreServiceClient.ClientCredentials.Windows.ClientCredential = creds;
            }
            return _instance;
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.