Sérialiser un objet hérité dans webservice
Bonjour,
Je rencontre un problème lorsque je tente de récuperer un objet par un webService developper vb.net 1.1 .
Je n'arrive pas à faire fonctionner une webmethod spécifiant une classe abstraite en retour et qui renvoit un objet de la classe fille.
La webmethode est :
Code:
1 2 3 4 5 6 7 8
| <webmethod()> _
<WebMethod()> _
Public Function GetProductBP(...) as ProductBP
return getProduct(..)
'Ou
return new SwapBP 'SwapBP class qui hérite de ProductBP
End Function |
ProductBP est une classe abstraite.
J'essaye alors de retourner un objet de la classe SwapBP qui hérite de ProductBP.
Hors, lorsque je fais ça,
J'ai l'erreur suivante :
Citation:
System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type Cdc.Trade.SwapBP was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
J'ai bien spécifié l'ensemble des attributs et des classes comme <Serializable()>
Lorsque je fais une WebMethod
Code:
1 2 3 4 5 6
|
<WebMethod()> _
Public Function getSwapBP() as SwapBP
return SwapBP
End Function |
Cela marche sans problème.
Quelle mot clé ou action dois je faire pour pouvoir renvoyer des objets de la classe fille ?
Merci de votre aide !