Working with WCF how it should modify this DataContract or code:
<DataContract()>
Public Class listaActos
Private _codigoActo As List(Of String)
<DataMember(IsRequired:=True)>
Public Property codigoActo() As List(Of String)
Get
Return _codigoActo
End Get
Set(ByVal value As List(Of String))
_codigoActo = value
End Set
End Property ...
which generates following response xml when serializing:
<a:listaActos>
<a:codigoActo xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<b:string>01672</b:string>
</a:codigoActo> </a:listaActos>
but I want to bo as follows:
<a:listaActos>
<a:codigoActo>01672</a:codigoActo>
<a:codigoActo>01673</a:codigoActo>
<a:codigoActo>01674</a:codigoActo></a:listaActos>
Thanks in advance!!
If your class
listaActosonly has the list ofcodigoActoin it, then you can make it a collection type (make it inherit fromList(Of String), for example). That will get you the XML shape you want with theDataContractSerializer.If it has more members, then you’ll need to use the
XmlSerializer, and define the class as such.The code below shows the list option.