Generate that Sitecore Commerce service proxy with latest Odata package


The Sitecore Commerce Engine solution comes with a project that is used to generate proxy after you have added your custom endpoints.

If you do not know how to generate service proxy, please refer to this article https://robearlam.com/blog/so-what-is-the-sitecore-commerce-serviceproxy

I wanted to share my experience with generating Sitecore Commerce Proxy using the latest version of Odata.

Everything worked out well until I had to refer to the latest OData versions. Once I referenced the latest OData versions (7.4.4) and generated the proxy, the project could not be built successfully. There was an error.

Could not find EdmxReader ..... global::Microsoft.OData.Edm.Csdl.EdmxReader.Parse(reader);

 

After a lot of workarounds, i found this --> EdmxReader was renamed to CsdlReader.

 

So I made changes to the CommerceOps.cs and CommerceShops.cs  and it worked. It looked like this : return global::Microsoft.OData.Edm.Csdl.CsdlReader.Parse(reader);

I don't like the idea of changing a generated class but I had a hard dependency to use the Odata 7.4.4 version. 

Once the OData versions are standardized across Engine and Sitecore, this issue should be resolved.

After this service proxy dll was added to the Sitecore project, there were issues with dll versions and the storefront didn't load. So, i used the following xdt file to remove old references and use the latest versions, which solved the challenge.

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
      <runtime>
        <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentassembly xdt:transform="RemoveAll" xdt:locator="Condition(starts-with(./_defaultNamespace:assemblyIdentity/@name,'Microsoft.OData.Client'))">
          dependentassembly>
          <dependentassembly xdt:transform="RemoveAll" xdt:locator="Condition(starts-with(./_defaultNamespace:assemblyIdentity/@name,'Microsoft.OData.Core'))">
          dependentassembly>
          <dependentassembly xdt:transform="RemoveAll" xdt:locator="Condition(starts-with(./_defaultNamespace:assemblyIdentity/@name,'Microsoft.OData.Edm'))">
          dependentassembly>
          <dependentassembly xdt:transform="RemoveAll" xdt:locator="Condition(starts-with(./_defaultNamespace:assemblyIdentity/@name,'Microsoft.Spatial'))">
          dependentassembly>         
          <dependentassembly xdt:transform="Insert">
            <assemblyidentity name="Microsoft.OData.Client" publickeytoken="31bf3856ad364e35" xmlns="urn:schemas-microsoft-com:asm.v1">assemblyidentity>
            <bindingredirect oldversion="6.0.0.0-7.4.4.20330" newversion="7.4.4.20330" xmlns="urn:schemas-microsoft-com:asm.v1">bindingredirect>
          dependentassembly>
          <dependentassembly xdt:transform="Insert">
            <assemblyidentity name="Microsoft.OData.Core" publickeytoken="31bf3856ad364e35" xmlns="urn:schemas-microsoft-com:asm.v1">assemblyidentity>
            <bindingredirect oldversion="6.0.0.0-7.4.4.20330" newversion="7.4.4.20330" xmlns="urn:schemas-microsoft-com:asm.v1">bindingredirect>
          dependentassembly>
          <dependentassembly xdt:transform="Insert">
            <assemblyidentity name="Microsoft.OData.Edm" publickeytoken="31bf3856ad364e35" xmlns="urn:schemas-microsoft-com:asm.v1">assemblyidentity>
            <bindingredirect oldversion="6.0.0.0-7.4.4.20330" newversion="7.4.4.20330" xmlns="urn:schemas-microsoft-com:asm.v1">bindingredirect>
          dependentassembly>
          <dependentassembly xdt:transform="Insert">
            <assemblyidentity name="Microsoft.Spatial" publickeytoken="31bf3856ad364e35" xmlns="urn:schemas-microsoft-com:asm.v1">assemblyidentity>
            <bindingredirect oldversion="6.0.0.0-7.4.4.20330" newversion="7.4.4.20330" xmlns="urn:schemas-microsoft-com:asm.v1">bindingredirect>
          dependentassembly>         
        assemblybinding>
      runtime>  
  configuration>

SEARCH ARTICLES