Ucommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.

Topics Payment Providers

Add a New Web Service

Ucommerce uses ServiceStack to open up web services to use for all sort of tasks, e.g adjusting the basket throughout the checkout flow, custom variant handling, anything you need.

You can use this capabililty to surface your own web services and extend the default set of services provided with Ucommerce.

Three things comes in play when you want to add a new web service:

  • Implement the specific webservice from ServiceStack interfaces.
  • Implement a single interface from Ucommerce with no methods needed IContainsWebservices.
  • Register the new web service interface with Ucommerce.

Purpose of IContainsWebservices

The interface is a so-called marker interface, which sole purpose is to let Ucommerce know that a given DLLs contains web services, hence the name :)

A marker interface contains requires no methods or properties, so basically no implementation required to use it.

    namespace UCommerce.Web.Api
    	/// <summary>
    	/// Marker interface for getting assemblies to register within ServiceStack AppHost.
    	/// </summary>
    	public interface IContainsWebservices

The reason for implementing the interface: IContainsWebservices is that ServiceStack on startup asks for a list of assemblies containing webservices for the AppHost.

We use that to our advantage, to make it possible to contribute to that list of assemblies through service stack - hence the inteface IContainsWebservices. When you register a component we will look up the assembly and provide that to ServiceStack, that then will know to scan your assembly with your located web services.

Because of this approach it is important that your actual web services are located within the same assembly as your registered component that implements IContainsWebservices.

Implement and Register IContainsWebservices

Implementing IContainsWebservices: (Once again, remember to have it in the same assembly as your actual web-services.)

    namespace MyUcommerceApp
    	public class AssemblyTag : IContainsWebservices

Create a new Webservices.config file and place it in Ucommerce/Apps/MyApp:

    		<component id="MyUcommerceAppWebServices"
    			service="UCommerce.Web.Api.IContainsWebservices, UCommerce.Web.Api"
    			type="MyUcommerceApp.AssemblyTag, MyUCommerceApp"/>

Having trouble to register your component? Please see Register a Custom Component.

Implement the Web Service

Finally you want to implement the actual web service, which is done by inheriting the Service class in the namespace ServiceStack.ServiceInterface.

    	public class MyWebService : ServiceStack.ServiceInterface.Service

That's it. You're all done.

Now if you need to learn more details on how to create a web service please read on in the next article "How to create a basket web service".