1

I am trying to use XML for my GeneralMappingStrategy in Asternet. I have my program working fine using List

such as:

        agiServer.MappingStrategy = new GeneralMappingStrategy(
        new List<ScriptMapping>()
        {
            new ScriptMapping() {
            ScriptName = "testIVR",
            ScriptClass = "Asterisk_Test.testIVR",
            }
        });

But I'd rather have it read an XML file as it says it can do in the documentation, however it does not seem to say anywhere what the XML format is required.

I have tried:

string pathtoxml = "test.xml";
agiServer.MappingStrategy = new GeneralMappingStrategy(pathtoxml);

With my XML as:

<?xml version="1.0"?>
<ScriptMapping>
<ScriptName>testIVR</ScriptName>
<ScriptClass>Asterisk_Test.testIVR</ScriptClass>
</ScriptMapping>

As a complete guess, seemed to make sense, but this won't compile, I get errors of:

System.InvalidOperationException: 'There was an error reflecting type 'System.Collections.Generic.List`1[AsterNET.FastAGI.MappingStrategies.ScriptMapping]'.'

Does anyone happen to know how to do this?

miken32
  • 42,008
  • 16
  • 111
  • 154
Dave
  • 351
  • 4
  • 18
  • That is one poorly documented library. [Looking at the code](https://github.com/AsterNET/AsterNET/blob/master/Asterisk.2013/Asterisk.NET/FastAGI/MappingStrategies/GeneralMappingStrategy.cs#L52), my only suggestion would be to wrap your `` element in a root element of some kind. It is using `XMLSerializer` to map the XML to `typeof(List)` so it may be looking for multiple `` elements in a wrapper. I don't know C#, but I do know Asterisk and XML so thought I'd throw in my 2 cents! – miken32 Apr 27 '17 at 04:31

1 Answers1

0

It appears that there was an issue with the Aster.NET library, I've now submitted the fix and it's been accepted. For anyone who has an issue on this in the future, the XML format is:

<?xml version="1.0"?>
<ArrayOfScriptMapping xmlns:xsi="w3.org/2001/XMLSchema-instance"; xmlns:xsd="w3.org/2001/XMLSchema">
<ScriptMapping>
<ScriptName>testIVR</ScriptName>
<ScriptClass>Asterisk_newTest.testIVR</ScriptClass>
</ScriptMapping>
</ArrayOfScriptMapping> 
Dave
  • 351
  • 4
  • 18