DigDes / SoapCore

SOAP extension for ASP.NET Core
MIT License
985 stars 370 forks source link

SoapInclude and XmlInclude attributes are ignored #1071

Closed lucamorelli closed 2 weeks ago

lucamorelli commented 2 months ago

I'm converting an app to asp.net core, and the classes are full of ArrayList, so I have to serialize them If I write a method like this

        [XmlInclude(typeof(DocsPaVO.ProfilazioneDinamica.Templates))]
        [SoapInclude(typeof(DocsPaVO.ProfilazioneDinamica.Templates))]
        public ArrayList getTemplates(string idAmministrazione)
        {
            try
            {
                var result = BusinessLogic.ProfilazioneDinamica.ProfilazioneDocumenti.getTemplates(idAmministrazione);
                //return result.OfType<DocsPaVO.ProfilazioneDinamica.Templates>().ToList();
                return result;
            }
            catch (Exception e)
            {
                logger.Debug("Errore in DocsPaWS.asmx  - metodo: getTemplates", e);
                return null;
            }
        }

When executed gives me this error

System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type DocsPaVO.ProfilazioneDinamica.Templates was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.

why is soapcore ignoring the attribute?

andersjonsson commented 2 months ago

Unfortunately support for XmlInclude and SoapInclude has not been implemented. You are more than welcome to give it a shot if you feel up to the task.

Otherwise I'd recommend using the more specific type as return type and experimenting to see if you can coax legacy clients to accept that

lucamorelli commented 2 months ago

could be nice, but I don't know how to do. Where can I find info?

andersjonsson commented 2 months ago

Unfortunately I don't know the details of those attributes but I imagine that you would need to add info in the wsdl (MetaBodyWriter and MetaWCFBodyWriter) and also some modifications in ServiceBodyWriter since the type of the responseObject will differ from the expected type.

I suspect that the error message you got came from ServiceBodyWriter

lucamorelli commented 2 months ago

I'm doing some tests and even removing the arraylist properties I have serialization problems. Do you have any suggestion on how troubleshoot serialization/deserialization problems?

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 weeks ago

This issue was closed because it has been inactive for 14 days since being marked as stale.