Problem:

Resolution:

Load the attached Microsoft.Dynamics.AX.NFe.dll file and register the .dll.  Then make the following code changes.

1.  Create a reference to the .dll in Dynamics AX

  1. Open the AOT, right click on “References” node and select “Add reference”.
  2. Click the “Browse…” button, select the DLL from the location as stated in step 1, and click OK. Ignore the warning messages if there are any.
    You may now see a new node named Microsoft.Dynamics.AX.NFe.
  3. If you are using Windows Server 2003, restart the AOS to make the DLL visible for AX.

2.  Change \Classes\EFDocMsgTransport_WebServiceV4_BR\createBinding

From:

System.ServiceModel.Channels.TextMessageEncodingBindingElement       messageEncodingBinding;

To:

Microsoft.Dynamics.AX.NFe.CustomTextMessageBindingElement         customTextMessageBindingElement;

From:

messageEncodingBinding =

//BP Deviation Documented

new System.ServiceModel.Channels.TextMessageEncodingBindingElement(

                          System.ServiceModel.Channels.MessageVersion::get_Soap12(),

                          System.Text.Encoding::get_UTF8());

To:

CustomTextMessageBindingElement = new Microsoft.Dynamics.AX.NFe.CustomTextMessageBindingElement("utf-8",

                     "application/soap+xml",

                    System.ServiceModel.Channels.MessageVersion::get_Soap12());

From:

bindingElementArray.SetValue(messageEncodingBinding, 0);

To:

bindingElementArray.SetValue(CustomTextMessageBindingElement, 0);

3.  Change \Classes\EFDocMsgFormat_XmlBase_BR\classDeclaration

Add:

Map                  charMap;

4.  Create a new method named createCharMap (\Classes\EFDocMsgFormat_XmlBase_BR\createCharMap)

protected void createCharMap()

{

    #define.Map2a('ãáàäâ')

    #define.Map2e('éèêë')

    #define.Map2i('íìîï')

    #define.Map2o('õóòöô')

    #define.Map2u('úùüû')

    #define.Map2c('ç')

    void insertIntoMap(str chars, str mapTo)

    {

        int i;

        for (i = 1; i <= strlen(chars); i++)

        {

            charMap.insert(char2num(chars, i), mapTo);

            charMap.insert(char2num(strUpr(substr(chars, i, 1)),1), strUpr(mapTo));

        }

    }

    charMap = new Map(Types::Integer, types::String);

    insertIntoMap(#Map2a, 'a');

    insertIntoMap(#Map2e, 'e');

    insertIntoMap(#Map2i, 'i');

    insertIntoMap(#Map2o, 'o');

    insertIntoMap(#Map2u, 'u');

    insertIntoMap(#Map2c, 'c');

}

5. Create a new method named getCanonicalFormat (\Classes\EFDocMsgFormat_XmlBase_BR\getCanonicalFormat)

protected str getCanonicalFormat(str _input)

{

    int i, currCharNum;

    str newString = _input;

    if (!charMap)

    {

        this.createCharMap();

    }

    for (i = 1; i <= strlen(newString); i++)

    {

        currCharNum = char2num(newString, i);

        if (charMap.exists(currCharNum))

        {

            newString = strpoke(newString, charMap.lookup(currCharNum), i);

        }

    }

    return newString;

}