Sitecore Commerce Service Proxy

Image
Sitecore Commerce

While working on Sitecore Commerce one would have come across Sitecore Commerce ServiceProxy project available in Sitecore Commerce Engine SDK. Rob Earlam has written a fantastic blog post So what is the Sitecore.Commerce.ServiceProxy? explaining in detail about the WHAT factor?With this blog post I am trying to share HOW such a proxy project can be created from scratch. Reasons as to why I did not wanted to use the existing Sitecore.Commerce.ServiceProxy project were,

  1. Wanted to have a project name that matches our project naming standards.
  2. Importing or reusing something existing do not give a full picture of what happening in the background and your fundamentals might not be clear.

As some pre-requisites for creating Sitecore Commerce Service Proxy project you should have,

  1. Visual Studio 2017
  2. An extension on top of VS 2017, OData Connected Service. The VSIX  file can be downloaded from here or can also be added directly to Visual Studio following steps mentioned here

Let’s create the project now,

  1. In your solution add a new class library project, I selected Class Library (.NET Core)

  2. Once the project is created you might want to clean up the project by removing Class1.cs file. Now right click on the project and select “Connected Service”.

    SC-Commerce-Proxy-2

  3. As we have already installed oData Connected Service you will see an option to create an endpoint. If you do not see such option, you might need to re-install or troubleshoot VSIX installation.

    SC-Commerce-Proxy-3

  4. Next step is to configure the endpoint and providing Service Name and Address. I named “CommerceShops” as the service name and the url.

    SC-Commerce-Proxy-4

  5. Specify File name as per your project standards. By default, it is Reference and I changed it to be “CommerceShops”.

    SC-Commerce-Proxy-5

  6. Have a look at the advance settings and what’s extra in there. For now, I left the default selection. As this is the first endpoint reference it is okay to keep these settings default. If you want to add another endpoint have a look at section “Add Multiple Endpoints” of this blog post

    SC-Commerce-Proxy-6

  7. Once you hit finish below processing can be seen

    SC-Commerce-Proxy-7


  8. Perform a build project as that would be our end goal to have a clean build project. If you face below error,The type or namespace name 'EdmxReader' does not exist in the namespace 'Microsoft.OData.Edm.Csdl' (are you missing an assembly reference?)Resolution to this issue can be found at Generate that Sitecore Commerce service proxy with latest Odata package by Kautilya Prasad

Add Multiple Endpoints

Now let’s add another endpoint reference to the project as there is a little change here as compared to while you were adding the first endpoint reference.Follow all steps from Point 1 to 5.Tick mark “Use a custom namespace…”, specify a custom namespace and hit finish. Make sure to rebuild your project.

SC-Commerce-Proxy-9

This brings an end to this blog post and yes remember to share your learnings on Sitecore as "Sharing is Caring".