Saturday, October 17, 2015

How to connect to the SDL Tridion 2011 core services client?

var binding = new WSHttpBinding {
     TransactionFlow = true,
     MaxReceivedMessageSize = 83886080,
     ReaderQuotas = { MaxStringContentLength = 83886080 },
     OpenTimeout = TimeSpan.FromMinutes(5),
     ReceiveTimeout = TimeSpan.FromMinutes(5),
     CloseTimeout = TimeSpan.FromMinutes(5),
     SendTimeout = TimeSpan.FromMinutes(5)
};

var address = new EndpointAddress("http://{domain}/webservices/CoreService2011.svc/wsHttp");

SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient(binding, address);

{domain} is the domain where the CMS Administration GUI is installed

Example: 

List all publications of where luizcgjr.blogspot.com is the domain that hosts the CMS Administration GUI

var  binding = new WSHttpBinding {
     TransactionFlow = true,
     MaxReceivedMessageSize = 83886080,
     ReaderQuotas = { MaxStringContentLength = 83886080 },
     OpenTimeout = TimeSpan.FromMinutes(5),    
     ReceiveTimeout = TimeSpan.FromMinutes(5),    
     CloseTimeout = TimeSpan.FromMinutes(5),    
     SendTimeout = TimeSpan.FromMinutes(5)
};

var address = new EndpointAddress("http://luizcgjr.blogspot.com/webservices/CoreService2011.svc/wsHttp");

using (SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient(binding, address)) {
     var publications = _client.GetSystemWideList(new PublicationsFilterData());    

     foreach (var publication in publications) {
          Console.WriteLine(publication.Title);
     }
}

No comments:

Post a Comment