5

I've set up the REST service (https://github.com/dd4t/DD4T.RestService.WebApi) to expose content, and would like to experiment with using the REST provider (https://github.com/dd4t/DD4T.Providers.Rest) to consume content within a DXA 1.2 application.

Struggling to find much documentation, but thought it was a matter of installing the REST provider NuGet package, and wiring up the dependency in the Unity configuration. Seems to be the case for a DD4T application, but (I could be wrong), with the DXA it's not so clear.

Is the DXA more tightly coupled with the SDLTridion2013sp1 provider, or can an alternative be used? If so, can anyone explain how this is configured? Checking the code, even if I can inject the REST provider I think I need to configure the service endpoint in some manner as well.

2
  • The latest version of DXA is 1.2 (which uses a custom build of DD4T 2.0 for the specific reason that we needed additional functionality which wasn't in the available NuGet/Maven packages yet), what version 2.0 are you exactly talking about? Commented Dec 2, 2015 at 10:41
  • My mistake Bart, I am using DXA 1.2. I've edited my question to reflect this. Commented Dec 2, 2015 at 10:51

2 Answers 2

3

You will have to change the Sdl.Web.Tridion project source code which will mean you will be breaking out of the DXA releases.

I simply removed the SDLTridion2013sp1 reference from the Sdl.Web.Tridion project, added a reference to DD4T.Providers.Rest through nuget in that same project, then updated the DD4TFactoryCache.cs file to use DD4T.Providers.Rest instead of DD4T.Providers.SDLTridion2013sp1.

You then need to update the Site Project's web.config to reference your DD4T Rest API by adding a new app setting:

<add key="DD4T.ContentProviderEndPoint" value="http://dd4trestapi.domain.com" />

Rebuild and deploy the Site Project and all should be working.

You may need to remove the DD4T.Providers.SDLTridion2013sp1.dll from the bin folder of your DXA website if it isn't cleared out in your deployment process.

UPDATE: It turns out that the above steps are just the start. The Component Linking is going through the Tridion API so you will need add a new GetLinkFactory method to Sdl.Web.Tridion.Mapping.DD4TFactoryCache

    internal static ILinkFactory GetLinkFactory(Localization localization)
    {
        lock (_linkFactories)
        {
            ILinkFactory linkFactory;
            if (!_linkFactories.TryGetValue(localization.LocalizationId, out linkFactory))
            {
                IPublicationResolver publicationResolver = new PublicationResolver(localization);
                IProvidersCommonServices providersCommonServices = new ProvidersCommonServices(publicationResolver, _logger, _config);
                IFactoryCommonServices factoryCommonServices = new FactoryCommonServices(publicationResolver, _logger, _config, CreateCacheAgent());
                linkFactory = new LinkFactory(
                    new TridionLinkProvider(providersCommonServices),
                    factoryCommonServices);
                _linkFactories.Add(localization.LocalizationId, linkFactory);
            }

            return linkFactory;
        }
    }

You will then need to update the ResolveComponentLink method in Sdl.Web.Tridion.Linking.LinkResolver to call the DD4T LinkFactory:

    private static string ResolveComponentLink(TcmUri tcmUri, Localization localization)
    {
        ILinkFactory linkFactory = DD4TFactoryCache.GetLinkFactory(localization);
        string link = linkFactory.ResolveLink(tcmUri.ToString());

        return link != string.Empty ? link : null;
    }

You are going to come across this with the Page Links, Binary Links and the Dynamic Lists too.

4

DXA 1.2 is for sure tightly coupled to the SDLTridion2013sp1 provider and we haven't looked at supporting the REST provider or what that would entail. So I really can't say anymore than that, I don't know right now if it should/could work.

Our current focus is the 1.3 release which adds SDL Web 8 support and for that we will introduce a SDLWeb8 provider for DD4T so you can use the CDaaS support which means a similar split of CD and Web Application.

We'll be releasing a blogpost with information how to use DXA 1.2 with the new DD4T SDLWeb8 provider so you don't have to wait for the 1.3 release. Technically you could already hook it up right now without a new provider, since SDL Web 8 is fully backwards compatible, but then you will have to add binding redirects in your web.config for the CD DLLs (talking about DXA .NET atm.).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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