I had already thought about it, but we have a lot of properties with underscore, we would have to change everyone manually.

We can do that, but I don't like it.

Maybe changing something in the method ##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject() that if "XMLNAME" is defined, use that name instead property real name? But I don't know where to do that...

We are using 2016.2.1 (Build 803U).

This is the way we generate JSON:

TEST>set x = ##class(test.msg.struct.TestXML).%New()
 TEST>set x.statusId = "111"
 TEST>set x.service = "222"
 TEST>do ##class(Ens.Util.JSON).ObjectToJSONStream(x, .obj1, "aelotu")
 TEST>w obj1.Read()
{       "statusId":"111",       "service":"222"}
 

And this is the definition of the object:

Class test.msg.struct.TestXML Extends (%SerialObject,%XML.Adaptor)
{
Property statusId As %String(MAXLEN = "", XMLNAME = "status_id");
Property service As %String(MAXLEN = "");
}

Yes, we have a .Net Gateway configured, and we have imported the .Net dll through the Studio wizard.

We have activated gateway log, but it doesn't say anything.

From an Ensemble Bussiness Operation we call the .Net method. The code is this:

Class bo.GenerarWord Extends EnsLib.DotNetGateway.AbstractOperation
{

Parameter INVOCATION = "Queue";

Method generarDocumento(pRequest As msg.WordRequest, Output pResponse As msg.WordResponse) As %Status
{
        #dim sc as %status
        #dim gateway as %Net.Remote.Gateway
        
        set pResponse = ##class(msg.WordResponse).%New()
        
        set sc = ..GetConnection(.gateway)
        
        if $$$ISERR(sc){
            set pResponse.mensaje = "Error ("_sc_"):"_$System.Status.GetErrorText(sc)
            
        }else{
            #dim ce as cysnet.MiClase.entity.ControlError
            #dim we as cysnet.MiClase.entity.WordEntity
            #dim plantilla as %String
            #dim documento as %String
            
            set ce = ##class(cysnet.MiClase.entity.ControlError).%New(gateway)
            set we = ##class(cysnet.MiClase.entity.WordEntity).%New(gateway)
            
            set plantilla = "C:\InterSystems\Ensemble\mgr\DLLWORDENS2\dlls\PlantillaTuneada.doc"
            set documento = "C:\InterSystems\Ensemble\mgr\DLLWORDENS2\dlls\"
            
            //set we.setuTitulo = "TITULO_ENS"
            
            do dao.EscribirWord(ce,plantilla,documento,we,"PRUEBA_ENS")
            
            $$$LOGINFO(ce.getuDebbug())
        }
        
        set pResponse.mensaje = "OK"
        Quit $$$OK
}

XData MessageMap
{
<MapItems>
        <MapItem MessageType="msg.WordRequest"> 
            <Method>generarDocumento</Method>
        </MapItem>
</MapItems>
}

The .Net code is this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using cysnet.MiClase.entity;
using System.IO;
using Microsoft.Office.Interop.Word;
 
namespace cysnet.MiClase
{
    public class MiClase
    {
        public String EscribirWord(ControlError ce, String fullPathPlantilla, String pathDocumento, WordEntity we, String numDocumento)
        {
 
            if (ce == null)
            {
                ce = new ControlError();
            }
            ce.Reset();
            ce.Debbug = fullPathPlantilla + " || " + pathDocumento + " || " + numDocumento + "  || ";
            ce.Debbug += " Iniciando método";
            String resultado = "";
            Application MSWord = new Application();
            Document documento;
 
            try
            {
                object oMissing = System.Reflection.Missing.Value;
                
                ce.Debbug += "RUTA DEL NUEVO DOCUMENTO:"+ pathDocumento + numDocumento +".docx";
 
                documento = MSWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
 
                ce.Debbug += " Abriendo plantilla Word";
                //Abrir Palntilla
 
                documento = MSWord.Documents.Open(fullPathPlantilla);
 
                ce.Debbug += " Escribiendo en marcadores";
                
                //Editar marcadores
                documento.Bookmarks["Titulo"].Range.Text = we.Titulo;
 
                ce.Debbug += " Guardando documento Word";
                //Guardar copia de la plantilla como documento
                documento.SaveAs(pathDocumento+numDocumento+".dot");
                
                ce.Debbug += " Cerrando documento Word";
                //Cerrar documento
                documento.Close();
                
                ce.Debbug += " Operación realizada con éxito";
            }
            catch (Exception e)
            {
                ce.MessageError = e.Message;
                ce.IsError = true;
            }
            finally
            {
                ce.Debbug += " Cerrando aplicación MsWord";
                //Cerrar la aplicación
                MSWord.Quit();
            }
 
            return resultado;
        }
    }
}

I have cleaned it a bit to be more legible. It has comments in spanish. I hope it doesn't matter.