fredag, april 07, 2006

.NET Remoting in Sitecore

The upcoming release of Sitecore (I guess it will be named Sitecore V5.3) will include a lot of new cool features. One of my favorite new features Im working on is remote invocation of Sitecore objects through .NET Remoting - giving you remote access to almost the entire Sitecore API (SitecoreKernel.dll) from any .NET client.

Hopefully the Remoting features will be stable enough to make the final release.

To enable your non-sitecore project (for example a Forms application) to use Sitecore Remoting, simply add a reference to Sitecore.Kernel.dll and you are good to go.

Access to Sitecore API is achieved through the new Sitecore.Remoting namespace, where you will have to know about two new types: The RemoteFactory and RemotingClientConfigurator. Only one line of code is necessary in order to get a remote reference to Sitecore:

Sitecore.Remoting.RemotingClientConfigurator.Configure(_sitecoreurl, "admin", "");



This snippet sets up the connection to Sitecore at a given url, with the username 'admin' and the empty password.

To access Sitecore objects, simply use the new RemoteFactory object (a remoting enabled version of the Factory class):

RemoteFactory factory = new RemoteFactory();



You now have access to all Sitecore objects. For example:

factory.GetDatabase("master").GetRootItem()



This will get you the root item of the master database.

In a later post, I will show how Sitecore can be managed and scripted through Microsofts new shell: MONAD using the new Remoting features.

Hopefully other more or less useful programs will be developed as a result of the introduction of .NET Remoting in Sitecore. I talked to Alexy Rusakov (Sitecore developer from our Ukraine division) about creating an addin to the Google toolbar showing a list of items who's workflow step is assigned to a specific user.

Only your imagination is the limit :-)


Regards

2 kommentarer:

Anonym sagde ...

What about _sitecoreurl? What value does it hold?

How do I connect to a particular instance of Sitecore when running multiple sites on the same machine?

Runi Thomsen sagde ...

The sitecoreUrl parameter should hold the location of the root of a Sitecore site. For example, if you have made a default installation on your local PC, the sitecoreUrl parameter should be: http://localhost

RemotingClientConfigurator translates this to: http://localhost/RemoteFactory.rem wich is the main resource to Remoting through Sitecore. It also sets up security by adding a logical call context that is used by the server to authenticate users.