Documentation Center

Resolving links in Web service responses

If an external affiliate site interacts with your Web site through the Content Delivery Web service, the responses it receives may contain links to Components, Pages or binaries. The same is true if a Tridion-managed Web site talks to the Web service. This topic explains how to configure your system to handle those links properly.

In the Linking configuration file, cd_link_conf.xml, you can map a Publication ID to a URL. The following example maps the Publication with ID 12 to the URL at http://localhost:8080/mysubsite:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration Version="6.0">
  <Publications>
    <Publication Id="12">
      <Host Domain="localhost" Port="8080" Protocol="http" Path="/mysubsite" />
      <Linking ComponentAnchors="true" />
    </Publication>
    <!-- Other Publication elements go here -->
  </Publications>
</Configuration>

Any Web service response containing a link to an item in Publication 12 will now contain a proper link to a URL on your Web site.

A special case is a Web service reponse in which a link points to a Content Delivery Web service call. So, for example, a call to the Web service returns a Component Presentation containing a link to http://localhost/cd_webservice/broker/page?pageURI="tcm:3-56-64". To resolve these types of links properly, a number of configuration steps must be made.

Updating the Linking configuration
Map your Publication ID to a URL in cd_link_conf.xml, as described above. There are also other ways to retrieve the URL corresponding to a Publication.
Build a custom Link Tag Renderer
The Content Delivery API contains a base class com.tridion.tcdl.renderer.LinkTagRenderer that you can extend to generate links exactly to your liking in the getWebserviceLinkString method.
Updating the Dynamic configuration

Open cd_dynamic_conf.xml and create or find the <Tags> section inside the <TCDLEngine> section. Now insert a Tag element referring to your custom link tag renderer:

<Tag Namespace="tcdl" Name="Link">
  <Handler Class="com.mycompany.MyLinkTagRenderer" AllowCodeBlock="true"/>
</Tag>

In addition, you also need to explicitly include Tag elements for all other TCDL tags, pointing to their default implementation classes. To do this, add the following code fragment inside your <Tags> section:

<Tag Namespace="tcdl" Name="ContentHeader">
  <Handler Class="com.tridion.tcdl.renderer.ContentHeaderTagRenderer" AllowCodeBlock="true"/>
</Tag>
<Tag Namespace="tcdl" Name="TargetGroup">
  <Handler Class="com.tridion.tcdl.renderer.TargetGroupTagRenderer" AllowCodeBlock="true"/>
</Tag>
<Tag Namespace="tcdl" Name="ComponentPresentation">
  <Handler Class="com.tridion.tcdl.renderer.ComponentPresentationTagRenderer" AllowCodeBlock="true"/>
</Tag>
<Tag Namespace="tcdl" Name="FirstLine">
  <Handler Class="com.tridion.tcdl.renderer.FirstLineTagRenderer" AllowCodeBlock="true"/>
</Tag>
<Tag Namespace="tcdl" Name="ContextProperty">
  <Handler Class="com.tridion.tcdl.renderer.ContextPropertyTagRenderer" AllowCodeBlock="true"/>
</Tag>
<Tag Namespace="tcdl" Name="Dependency">
  <Handler Class="com.tridion.tcdl.renderer.DefaultTagRenderer" AllowCodeBlock="true"/>
</Tag>
<Tag Namespace="tcdl" Name="Comment">
  <Handler Class="com.tridion.tcdl.renderer.CommentTagRenderer" AllowCodeBlock="true"/>
</Tag>
<Tag Namespace="tcdl" Name="IncrementTrackingKey">
  <Handler Class="com.tridion.tcdl.renderer.IncrementTrackingKeyTagRenderer" AllowCodeBlock="true"/>
</Tag>
<Tag Namespace="tcdl" Name="TaxonomyControl">
  <Handler Class="com.tridion.tcdl.renderer.TaxonomyTagRenderer" AllowCodeBlock="true"/>
</Tag>
<Tag Namespace="tcdl" Name="PositionMarker">
  <Handler Class="com.tridion.tcdl.renderer.PositionMarkerTagRenderer" AllowCodeBlock="true"/>
</Tag>