Soap WebService Server with .NET6 and XML attributes

I'm migrating a .NET Framework SOAP Web Service (Server Side) to a new .NET 6 project. I used DataContract and DataMember with no issues until I reached a WS which had to return XML attributes.

Then I read the official documentation but was not able to find a way to return attributes inside my XML elements.

They suggest to use XmlSerializer and the "XmlAttribute" attributes, but they seems to be ignored by .NET 6.

Am I forced to roll it back to .NET Framework or is there anything I can do?

Here is a simple example that's not working:

Of course if I switch it back to DataModel it works, but I am not able to have XML attributes. What I want to achieve is

<BankingTransaction operation="opName">
    <amount>100</amount>
</BankingTransaction>

THE INTERFACE

[ServiceContract]
[XmlSerializerFormat]
public interface IBankingService
{
    [OperationContract]
    public BankingTransaction ProcessTransaction();
}

THE SERVICE IMPLEMENTATION

public class BankingService: IBankingService
{
    public BankingTransaction ProcessTransaction()
    {
        BankingTransaction bt = new BankingTransaction();
        bt.amount = 1000;
        bt.Operation = "Test";
        return bt;
    }
}

THE MODEL

public class BankingTransaction
{
    [XmlAttribute]
    public string Operation;
    [XmlElement]
    public int amount;
}


Thanks A PIECE OF THE program.cs file


builder.Services.TryAddSingleton<IBankingService, BankingService>();
app.UseSoapEndpoint<IBankingService>("/Service.asmx", new SoapEncoderOptions());
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum