Using the SDK in a standalone application

Posted by Community Admin on 05-Aug-2018 22:41

Using the SDK in a standalone application

All Replies

Posted by Community Admin on 16-Aug-2010 00:00

I have a standalone application that needs to access the objects and database of a SF4.0 beta site project. I need to modify the contents of this project - i.e. add new pages, etc. and the best way to do it would be to use the methods provided by the SDK.

Now, after I copy and reference the files from the /bin folder of the site project, I try to create a new PageManager with this line:

var pManager = PageManager.GetManager();

and of course I get some sort of error, in this case:

The type initializer for 'Telerik.Sitefinity.Modules.Pages.PageManager' threw an exception.

My question is - what kind of context and initialization should I provide in order to use the Sitefinity "engine" in a standalone application and is that even possible?

Posted by Community Admin on 17-Aug-2010 00:00

Hello Lupi,

Thank you for using our services.

Since you need to access data of a Sitefinity website in another application you will have to use web services. What you have to do is to create web services which will access this data, serialize it and return it. Then you need to host those services on your Sitefinity website and then add Service References to those services in your application. Then you will call the webservice to get your data and return it. Bellow are linked couple of samples which explain how to create webservices which use Sitefinity API. The samples are for 3.x version however the principle is the same in Sitefinity 4.0. The idea is that your webservices are running in the context of the Sitefinity website and all providers are initialized in the context of this website.
Enable loading of CMS pages through an AJAX Web Service
Use the Content Manager API in a Web Service

Regards,
Radoslav Georgiev
the Telerik team


Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Posted by Community Admin on 20-Aug-2010 00:00

Hummmm,


Hi Radoslav, I am not  totally sure I understand your response to Lupi.
Why do we need to create new Web Services to access the objects and data of the site?  That is the case for 3.x, but in 4.0 I don't think that is the case because 4.0 already comes with REST services (svc files) included in the services directory that can be accessed by any application to accomplish this.  The only time we will need to create NEW web services is to publish an API to access our own modules or controls hopefully by following your guidelines in creating REST Web services so that it looks and behaves in the same manner as your services.

Please correct me if I am wrong as this is very important for me and I still can not get your RESTFUL services to work based on the current Beta.

Thanks a million
Lino

Posted by Community Admin on 20-Aug-2010 00:00

The team is preparing some Sitefinity 4.0 REST API examples.  I'm as anxious as everyone else to dig into this.


As an aside, I'm hoping to create a WPF app. + Sitefinity 3.x service that can be used to migrate blog posts from Sitefinity 3.x to Sitefinity 4.0.  I'm anxious to get Sitefinity Watch running on Sitefinity 4.0.  The Sitefinity 4.0 web services open up a lot of opportunities.

Lino, I know you're planning some interesting apps as well.  

We'll know more soon.

Gabe Sumner
Telerik | Sitefinity CMS

Posted by Community Admin on 25-Nov-2010 00:00

Hi,

I also need to access Sitefinity 4 database from my standalone application.
Is web service my only option or there is another way (code samples would really help).

Thanks,
Neb

Posted by Community Admin on 25-Nov-2010 00:00

Hi Neb,


To access the Sitefinity 4 DATABASE, no you don't need to use the REST Web Services API.  You can code your standalone application against the database directly, HOWEVER, I don't recommend for you to do that and spend the extra time to work with Sitefinity 4 through the REST API to make sure you are doing things in Sitefinity and following the Workflow the way that the system was intended to be used.
The Regular API and the new FLUENT API can not be used from standalone applications as that kind of API requires that you use it from inside the context of the site itself in ASP.NET.

Best of luck to you
Lino Tadros
Falafel Software Inc.
P.S We will be releasing a lot of samples, videos and standalone applications (Mobile) that will illustrate the power of the REST API.

Posted by Community Admin on 25-Nov-2010 00:00

Hi Lino,

Thanks for a quick reply.
To give you more details, I have a standalone application that has a couple of "Latest news" pages whose content I need to populate from our Sitefiniti 4 database. That is really all my application need from CMS.

I originally planed to use the sample provided in Sitefinite 4 developers guide:

public void FindNews(string newsTitle, string author)

    NewsManager manager = NewsManager.GetManager(providerName);
    NewsItem item = manager.GetNewsItems()
                      .Where(t => t.Title == newsTitle)
                      .Where(t => t.Author == author)
                      .Where(t => t.Status == ContentLifecycleStatus.Live)
                      .Single();
but not sure how to instantiate/create a providerName.

Can this approach work at? Is there anything else you can recommend for this scenario?

Thanks,
Neb

Posted by Community Admin on 25-Nov-2010 00:00

Hello Neb,

Thank you for getting back to us.

As Lino has pointed out the Fluent API or even the native one has to be used in the context of the Sitefinity project (website) and not in the context of your standalone application. If you call the managers or Fluent API from your application the providers will return null.

The providerName variable in the above sample is of type string you can pas for example "News". Please note that this code will work if called in a web service hosted on your Sitefinity website. For more information on how to implement your own services you can take a look at this article: Implementing your own WCF REST service.


Best wishes,
Radoslav Georgiev
the Telerik team


Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Posted by Community Admin on 11-Sep-2012 00:00

The link to how to implement your own REST services 404s.

Posted by Community Admin on 13-Sep-2012 00:00

Hi,

Further information about implementing your own RESTful WCF services can be found in the following Sitefinity documentation section.

Kind regards,
Stefani Tacheva
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

This thread is closed