Developer forum

Forum » Integration » Connect to completely custom ERP system

Connect to completely custom ERP system

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

What's the best practice to connect to a remote / custom ERP system these days? In the past I would inherit Connector like Dynamicweb.Ecommerce.Integration.Connectors.Nav did and then implement the ProcessRequest method. I would then configure the DynamicWeb service to use that connector.

Is this still possible and recommend? Obviously, if the new ERP system implemented OData I would use that. But what if it doesn't? (The use case I need this for doesn't). I tried to find some old types in the source code and on NuGet but many seem to have gone (like Dynamicweb.Ecommerce.Integration.Connectors.Nav).

Any insights would be much appreciated!

Imar

 


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Imar,
it is still possible to implement it using a custom connector (the Connectors packages were not published to Nuget but the code still exists in the repositories)
and then connect to the regular DynamicwebService (batch addins and Live integration).
Or alternative solution could be to consider if it is possible to use the Endpoint Management to connect to the remote system using existing Authentication types:
OAuth(most popular today) or Basic or Bearer token.
The authentication types that are in DW9 will be converted to add-ins in DW10 so it will be possible to have its own custom authentication type implemented for DW10.
But support of the Dynamicweb service is still available in both DW9/DW10.
BR, Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks for the elaborate answer Dmitrij, that's very helpful.

So when using Endpoint Management, where would my custom functionality be? Are these just HTTP wrappers or would I have to inherit a base class and implement my own logic?

Looking at the documentation you linked to, it seems it's primarily either OData or SOAP for a DW Service. Then "This is not to say that the tool cannot be useful with other RESTful or SOAP-based endpoints, e.g. an Azure Table or a proprietary SOAP web service" seems to suggest there are extensibility points somewhere?

Thanks!

Imar

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Having custom functionality in the Endpoint Management is not possible for DW9, but would be possible in DW10 later.

There is no extensibility points for the EndpointManagement in DW9, so having a custom connector seems is the only available option (if existing functionality can not be used)
BR, Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

So, just to make sure I fully get this: when I am on DW 9 and I have to connect to, say, a REST service, I can only do it with the connector service and a custom Connector? 

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Yes, however it looks like the ConnectorService api with ProcessRequest method is not convenient for the REST apis where you would need to change requests urls/query string parameters.

So you can also look on implementing own Project that can handle the communications with ERP and use it in the custom batch add-ins/custom data integration provider.
So it is possible to save the basic endpoint information in the regular EndpointManagement and then use this enpoint to make own requests/response handlings in the custom code.
So some part of the EndpointManagement can be used for that: fx EndpointService.GetEndpointById.
You can look into the Dynamicweb.DataIntegration.Providers.ODataProvider source code where it uses EndpointService to get the actual base endpoint and then uses the HttpRestClient where it adjusts the neeeded parameters and runs the custom requests

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks again Dmitriy, that helps a lot. 

>>and use it in the custom batch add-ins/custom data integration provider.

Right, so this would be batch only, and for Live I would still need to create a plugin to convert from DW XML to rest and back? That's the direction we're heading in currently, so would be nice to get confirmation.

Imar

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Yes, you would need a custom Live integration since the standard doesn't support a custom connectors. Also the current standard Live integration extensibility events could not allow the flexibility to run a custom requests/responses.
You can look on Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Connectors.ConnectorBase and try to make an own connector
BR, Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Cool, thanks again. We're currently working on extending Connector and plug that into the service. For anyone who needs this in the future, here's how the connector code can look:

  public class MyCustomConnector : Connector
  {
    public override string ProcessRequest(string request)
    {
      var logger = LogManager.GetCurrentClassLogger();
      logger.Info(request);
      var config = (NameValueCollection)ConfigurationManager.GetSection("MyCompanyConnector");
      var url = config["RestUrl"];
      var content = GetJsonContent(request);

      try
      {
        using (var client = new RestClient(GetDefaultHeaders(config)))
        {
          var result = client.PostAsync(url, content).GetAwaiter().GetResult();
          if (result.IsSuccessStatusCode)
          {
            var response = result.Content.ReadAsStringAsync().GetAwaiter().GetResult();
            return response;
          }
          logger.Error($"Error: {result.StatusCode}");
        }
      }
      catch (Exception ex)
      {
        logger.Error($"Error: processing request", ex);
      }
      return "Failed to process request.";
    }
  }

(Still in early demo stages, but this is roughly what it'll eventually do: post to another REST service and return the response.

The connector's DLL is then added to the DynamicWeb service's folder and registered like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="MyCompanyConnector" type="System.Configuration.NameValueSectionHandler"/>
  </configSections>
  <MyCompanyConnector>
    <add key="RestUrl" value="https://example.com"/>
  </MyCompanyConnector>
  <appSettings>
    <add key="ServiceName" value="DynamicwebServiceMyCompany"/>
    <add key="TestMode" value="False"/>
    <add key="TestOutputFile" value="C:\Projects\_temp\Test.xml"/>
    <add key="TestOutputFolder" value="C:\Projects\_temp\TestFiles"/>
    <add key="Secret" value="SecretHere!!"/>
    <add key="WebserviceURI" value="http://localhost:8091/DynamicwebServiceMyCompany"/>
    <add key="DebugInfo" value="True"/>
    <add key="ConnectorType" value="MyCompany.LiveIntegration.Connectors.MyCustomConnector"/>
  </appSettings>
</configuration>

Imar

 

 

You must be logged in to post in the forum