You are here: Catalog System > Using Catalog Web Services

Using Catalog Web Services

Overview

Mediachase Catalog System relies on Windows Communication Foundation API to enable web services access. To work with an API you will need to add references to EPiServer Commerce libraries and there is no need to generate proxy classes for a web service.

Steps to Configure

1.Setup "Integration Service" web site by following the steps in the section Catalog Web Service Integration Service Site.

2.Configure a console application by adding appropriate configuration files and settings in app.config (see CommerceFramework configuration section).

3.Replace address with the URL of your Integration Service site.

You will need to add the following configuration to app.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="CommerceFramework">
<section name="Application" type="Mediachase.Commerce.Core.CoreConfiguration,Mediachase.Commerce"/>
<section name="Catalog" type="Mediachase.Commerce.Catalog.CatalogConfiguration,Mediachase.Commerce"/>
</sectionGroup>
</configSections>
<!-- Framework configuration -->
<CommerceFramework>
<!-- Application Configuration -->
<Application configSource="Configs\ecf.app.config"></Application>
<!-- Catalog Configuration -->
<Catalog configSource="Configs\ecf.catalog.config"></Catalog>
</CommerceFramework>
<system.serviceModel>
<client>
<!-- Replace address with the URL of your Integration Service site -->
<endpoint name="CatalogConfigurationWS" address="http://localhost/5.1/release/is/CatalogService.svc" binding="wsHttpBinding" bindingConfiguration="CommerceServiceBinding" contract="Mediachase.Commerce.Catalog.ICatalogSystem"/>
</client>
<bindings>
<wsHttpBinding>
<binding name="CommerceServiceBinding">
<!-- UsernameToken over Transport Security -->
<security mode="None">
<message clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
</configuration>

and modify ecf.app.config and ecf.catalog.config to point to a web service:

<Connection connectionStringName="CatalogConfigurationWS" useWebServices="true" />

4. Add the following references (add the Mediachase references from the bin folder in your Integration Services site):

Using API

Once application is properly configured the API for the Web Services is the same as when using catalog API directly.

Method that prints catalog names:

public void CatalogSystem_UnitTest_Integration_PrintAllCatalogs()
{
CatalogDto catalogDto = CatalogContext.Current.GetCatalogDto();
foreach (CatalogDto.CatalogRow catalogRow in catalogDto.Catalog)
{
Console.WriteLine(catalogRow.Name);
}
}

Method that searches for entries:

public void CatalogSystem_UnitTest_Integration_EntrySearch()
{
ICatalogSystem system = CatalogContext.Current;
// Get catalog lists
CatalogDto catalogs = system.GetCatalogDto();
int returnedRecords = 0;
foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
{
string catalogName = catalog.Name;
// Get Catalog Nodes
CatalogSearchParameters pars = new CatalogSearchParameters();
CatalogSearchOptions options = new CatalogSearchOptions();
options.RecordsToRetrieve = 1;
pars.FreeTextSearchPhrase = "";
pars.CatalogNames.Add(catalogName);
Entries entries = system.FindItems(pars, options, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
returnedRecords += entries.TotalResults;
}
Assert.IsTrue(returnedRecords > 0, "Search returned no results.");
}

How it works

The Catalog System implements ICatalogSystem interface that is used to access the underlying functionality. There are two implementations of these interface, one is called "CatalogContextImpl" and another "CatalogContextProxyImpl". The "CatalogContextImpl" is used when using API directly and "CatalogContextProxyImpl" is used when using Web Services. CatalogContext.Current property looks at the configuration settings and returns the appropriate implementation.

We have provided a Windows Application sample in the .zip file below. This .zip file contains a Visual Studios solution file that you can run and it will execute the code listed above and return the names of your catalogs:

Download the Catalog Web Services Client Example from EPiServer World

Troubleshooting

After you have setup Integration Services site, go to the address specified, for example "http://localhost/5.2/release/is/CatalogService.svc". It should open the page describing the web service.

 

 


Last updated: 2011-05-17 | Copyright © EPiServer AB | Send feedback to us