Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Image Service

Describes the options for hosting the Image Service outside the Optimizely Content Management System (CMS) application.

By default, the Optimizely Content Management System (CMS) Image Service runs in the same application domain as the CMS site. For performance and scalability reasons, you can host the CMS Image Service in another process and use Windows Communication Foundation to access it, such as an ASP.NET Web Application, a Console Application, or a WinForms Application.

Host with IIS HTTP / WAS

If you host using IIS and the HTTP protocol or with Windows Activation Services (Windows Server 2008 or Windows Vista only), you should create a file with the SVC extension somewhere on the website. The SVC file should contain the following line of code:

<%@ ServiceHost Language="C#" Debug="true" Service="EPiServer.ImageLibrary.ImageService" %>

You can configure the Windows Communication Foundation client and service from code and configuration files. Configuration files are the most flexible because you can change endpoint addresses and binding types without touching the code.

Image Service host application configuration

The following configuration example shows an Image Service hosting application that uses the NET.TCP protocol. Place the <system.serviceModel> section in the application's app/web.config file as a child of the <configuration> section.

<system.serviceModel>
      <services>
        <service name="EPiServer.ImageLibrary.ImageService">
          <endpoint address="net.tcp://serverxyz:8000/ImageService"
                    binding="netTcpBinding"
                    bindingConfiguration="ImageServiceBinding"
                    contract="EPiServer.ImageLibrary.IImageService" />
        </service>
      </services>
      <bindings>
        <netTcpBinding>
          <binding name="ImageServiceBinding"
                   maxReceivedMessageSize="20000000">
            <readerQuotas maxArrayLength="20000000" />
          </binding>
         </netTcpBinding >
      </bindings>

If you want to use the IIS non-HTTP hosting on Windows Server 2003 or Windows XP option, then add the following line to the configuration file as a child of the <system.web> and <httpModules> section:

<add name="ImageServiceModule" 
     type="EPiServer.ImageLibrary.ImageServiceModule, EPiServer.ImageLibrary" />

Configure the CMS website

To use the remote Image Service on an Optimizely CMS website, you must also configure WCF in its web.config file. Assuming you configured the Image Service to use the NET.TCP protocol and is listening on port 8000 or ImageService on serverxyz, the following configuration is required:

<system.serviceModel>
      <client>
        <endpoint name="ImageServiceClientEndPoint"
                  address="net.tcp://serverxyz:8000/ImageService"
                  binding="netTcpBinding"
                  bindingConfiguration="ImageServiceBinding"
                  contract="EPiServer.ImageLibrary.IImageService" />
      </client>
      <bindings>
        <netTcpBinding >
          <binding name="ImageServiceBinding" maxReceivedMessageSize="20000000">
            <readerQuotas maxArrayLength="20000000" />
            <security mode="None">
            </security>
          </binding>
        </netTcpBinding >
      </bindings>

📘

Note

The client endpoints name MUST be ImageServiceClientEndPoint because this is the name that CMS looks for when deciding if the Image Service should be accessed using Windows Communication Foundation. If there is no client endpoint with the name ImageServiceClientEndPoint, then a local version of the Image Service is instantiated by CMS in the same application domain.

Host with a Console or WinForms application

In the startup code for the application, create a System.ServiceModel.ServiceHost instance passing in the ImageService type:

//Create a service of for the type EPiServer.ImageLibrary.ImageService
    ServiceHost serviceHost = new ServiceHost(typeof(ImageService));

Open the service host to start the listening operation:

//Start the service
    serviceHost.Open();

📘

Note

The call to Open is non-blocking. Therefore, in a console application you should have code to stop the application exiting immediately:

Console.WriteLine("Press any key to stop the service");
    Console.ReadLine();

Always close the service host before the application exits with an explicit call to Close() or by employing the C# using the statement:

//Close the service
    serviceHost.Close();

Host with IIS and a Non-HTTP Protocol on Windows Server 2003 / XP

Microsoft does not support hosting a WCF service in IIS on Windows Server 2003 or Windows XP using a non-HTTP protocol (for example, NET.TCP, NET.PIPE), but you can do it, and it works using the help of an HTTP module.

The EPiServer.ImageLibrary assembly supplies such a module to support this hosting option. You do not need code for this; only configuration.

The main disadvantage of this hosting method is that the requests to the WCF service do not go through the IIS HTTP pipeline and have no effect on the web application's lifetime. You must activate the web application hosting the service through a normal web request to call the HTTP module and open the service host.

Related topics