Q:

Implement SOAP 1.2 service in asp.net core

I'm trying to implement OCPP 1.5 under ASP.Net Core 2.2. The standard makes use of SOAP 1.2. The issue comes from poor interpretation of the MessageHeader attribute. Properties with MessageHeader should be in header, but they are not. 
Source code: https://github.com/delianenchev/OcppDemo
I use SoapCore under ASP.Net Core. My initialization looks like this:
        var transportBinding = new HttpTransportBindingElement();
        var textEncodingBinding = new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressingAugust2004, System.Text.Encoding.UTF8);
        var customBinding = new CustomBinding(transportBinding, textEncodingBinding);
        app.UseSoapEndpoint<ISampleService>("/SOAP/service.wsdl", customBinding, SoapSerializer.DataContractSerializer);

My demo model with the MessageHeader and MessageBodyMember attributes.
[MessageContract]
public class MessageModelRequest
{
    [MessageHeader]
    public string Id { get; set; }

    [MessageBodyMember]
    public string Name { get; set; }

    [MessageBodyMember]
    public string Email { get; set; }
}

I test API with SoapUI. 
This is my API under ASP.NET core with SoapCore.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/" xmlns:mod="http://schemas.datacontract.org/2004/07/Models">
   <soap:Header/>
   <soap:Body>
      <tem:TestMessageModel>
         <!--Optional:-->
         <tem:inputModel>
            <!--Optional:-->
            <mod:Email>?</mod:Email>
            <!--Optional:-->
            <mod:Id>1</mod:Id>
            <!--Optional:-->
            <mod:Name>?</mod:Name>
         </tem:inputModel>
      </tem:TestMessageModel>
   </soap:Body>
</soap:Envelope>

Correct API from WCF project for IIS.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header>
      <tem:Id>34</tem:Id>
   </soapenv:Header>
   <soapenv:Body>
      <tem:MessageModelRequest>
         <!--Optional:-->
         <tem:Email>3</tem:Email>
         <!--Optional:-->
         <tem:Name>4</tem:Name>
      </tem:MessageModelRequest>
   </soapenv:Body>
</soapenv:Envelope>

A:

Well, judging by the source code of SoapCore it seems to support message headers for reading the SOAP message as it uses MessageEncoder for that purpose which knows exactly how to read a SOAP message, but when it comes to serializing a response in your case it uses a native DataContractSerializer for writing the body that ignores any message contract attributes you have on your class and furthermore it doesn't have any part for writing header, just the message body.
So I guess you need to implement the header support in response messages by yourself.
First of all, add IgnoreMemberAttribute (or XmlIgnoreAttribute if you switch to SoapSerializer.XmlSerializer) on the properties you intend to add to your response message header so that data contract serializer doesn't add them to the body of the message.
Finally, you will need to locate the properties decorated with MessageHeader attribute manually and add them to your header. Luckily SoapCore has multiple options for doing that as suggested here.
As alternative if you plan to include the source of SoapCore in your solution, you could easily achieve the goal somewhere along these lines. It's easy to do so because at this place you have the full control of the message and the response you got from your service method. With the aid of reflection, you can easily find the properties of responseObject which need to be moved to the header and just forward them to responseMessage.Headers.
I know it's a bit nasty, but well... this is the price of using SOAP in .NET Core.

