11

I have just completed my first End-2-End testing in SDL Web 8 where I have created, published (through topology manager) and displayed a piece of content in a .NET Web Application. This feels like a major milestone.

To test some of the functionality I tried loading various items like page content and dynamic links using the new .NET RESTful API.

One of my test cases is resolving a component link with the following test code.

ComponentLink compLink = new ComponentLink(777);
Link myCompLink = compLink.GetLink(12, 124704,8, "targert='wow'", "My text", true, true);

The link resolves correctly, and the resulting URL property contains something like "http://my.domain.com/myfirstwebapp/test.aspx". I was very suprised to see an absolute URL here.

I recognize the domain from when I set up a Website with Topology Manager, and the 'myfirstwebapp' from the WebApplication I set up with Topology Manager. In many cases this makes sense. However in our case we have multiple sites and apps consuming this content, and as such need to leverage relative URLs.

When I look in the LINK_INFO table of the Broker Database I see the URLs I would like to use.

Is there a way to configure the micro services to return relative URLs rather than absolute ones?

2 Answers 2

9

Yes, there is. In the cd_link_conf.xml of the (Session-enabled) Content Service there is a OverrideDiscoveryService attribute. If you set that to true, the Content Service will switch back to old-style link resolving using the mappings defined in cd_link_conf.xml and if you don't define any mappings in there, you will get relative URLs.

Unfortunately, the implementation of this setting is defective; after a while it will revert to using the Discovery Service (and absolute links) anyways. This defect is fixed in the upcoming 8.1.1 release.

3

In addition to Rick's correct answer...

You can indeed use the OverrideDiscoveryService to get relative URLs.

The default cd_link_conf.xml in the content, session and preview micro services contains the following comment which I found confusing.

OverrideDiscoveryService - specifies whether OData discovery endpoint configuration should be overridden

Since you use the discovery service to configure the publication mappings, and not the <Publications> element in the cd_link_conf.xml it looks like the OverrideDiscoveryService is not applicable, the publications mapping in the cd_link_conf is not used after all...

When looking in it at a bit more detail it turns out to be a simple yet effective logic:

  1. By default, with OverrideDiscoveryService="false" the discovery service provides a publication URL which is used by dynamic linking to make an absolute URL. i.e. http://example.com/nl/news/article.html
  2. When OverrideDiscoveryService="true" the publication mapping in the discovery service is ignored and the <Publications> mapping in the cd_link_conf.xml is used.
  3. When OverrideDiscoveryService="true" and there are no mappings in <Publications>, the dynamic linking returns relative URLs, i.e. /nl/news/article.html.

By the way, the links are resolved by the content service (or session service when you are in XPM session preview). The CIL (Content Interaction Library) in the web application does a request to the content service to resolve dynamic links.

2
  • That's great info Jan Commented Apr 13, 2017 at 14:24
  • Hi Jan/Rick, within the same context, what exactly we need to configure to use 2 webapplication sharing same CM and CD. How microservices will segregate in picking the right data for each site.. In my case i am getting data from 1st set of publications for 2n website. see tridion.stackexchange.com/questions/17558/… Commented Jul 22, 2017 at 6:30

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.