Developer forum

Forum » Dynamicweb 10 » Custom Data Integration Provider - Provider Selection Not Persisting

Custom Data Integration Provider - Provider Selection Not Persisting

Martin Moen
Reply
Hi forum!

I have an issue with custom integration provider not persisting the settings.
DynamicWeb Version: 10.18.12
 
Issue:
Custom Integration Providers (BaseProvider) are not persisting in Activity Groups.
 
Questions:
 
Attachments:

Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Martin,
it is supported, but your code is not complete, so that is why it doesn't work.
Try to add:
1) one more constructor:
public TestSimpleProvider(XmlNode xmlNode)
        {
            ArgumentNullException.ThrowIfNull(xmlNode);
            
            foreach (XmlNode node in xmlNode.ChildNodes)
            {
                switch (node.Name)
                {
                    case "SourceTestParameter":
                        if (node.FirstChild is not null)
                        {
                            SourceTestParameter = node.FirstChild.Value ?? "";
                        }
                        break;
                    case "DestinationTestParameter":
                        if (node.FirstChild is not null)
                        {
                            DestinationTestParameter = node.FirstChild.Value ?? "";
                        }
                        break;
                    case "Schema":
                        _schema = new Schema(node);
                        break;                    
                }
            }
        }

2)Change SaveAsXml method as shown here:
public override void SaveAsXml(XmlTextWriter textWriter)
        {
            if (textWriter is null)
                return;
            textWriter.WriteElementString("SourceTestParameter", SourceTestParameter);
            textWriter.WriteElementString("DestinationTestParameter", DestinationTestParameter);
            ((ISource)this).GetSchema().SaveAsXml(textWriter);
        }

BR, Dmitrij

Votes for this answer: 1
 
Martin Moen
Reply

Hi Dmitrij!

Thank you for the solution! The XmlNode constructor and SaveAsXml fixes worked perfectly - settings now persist as expected.

However, we discovered a critical gap in the official documentation at:
https://doc.dynamicweb.dev/documentation/extending/integrations/newintegrationprovider.html

What's missing:

  1. XmlNode constructor - Completely absent from documentation, yet absolutely required for settings persistence
  2. Element name casing - Not specified that SaveAsXml element names must match property names in PascalCase
  3. Null check in SaveAsXml - Example doesn't include if (textWriter is null) return;
  4. Settings lifecycle - No explanation of when each constructor is called or why both are needed

Current documentation shows:

  • ✅ How to serialize (Serialize method)
  • ✅ How to write XML (SaveAsXml method)
  • ❌ How to deserialize (XmlNode constructor) ← Missing!

Suggested addition (below). Without this constructor, providers appear to save successfully (200 OK) but settings are lost when reopening the activity - exactly the issue we experienced.
Would greatly appreciate if this could be added to the documentation to help future developers avoid this confusion.

/// <summary>
/// Constructor for deserializing saved settings from XML
/// REQUIRED for settings persistence
/// </summary>
public MyProvider(XmlNode xmlNode)
{
    ArgumentNullException.ThrowIfNull(xmlNode);
   
    foreach (XmlNode node in xmlNode.ChildNodes)
    {
        switch (node.Name)
        {
            case "SourceParameter":
                if (node.FirstChild is not null)
                {
                    SourceParameter = node.FirstChild.Value ?? "";
                }
                break;
            case "Schema":
                _schema = new Schema(node);
                break;
        }
    }
}

 

You must be logged in to post in the forum