Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7933111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:13:42+00:00 2026-06-03T21:13:42+00:00

Working with WCF how it should modify this DataContract or code: <DataContract()> Public Class

  • 0

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!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:13:43+00:00Added an answer on June 3, 2026 at 9:13 pm

    If your class listaActos only has the list of codigoActo in it, then you can make it a collection type (make it inherit from List(Of String), for example). That will get you the XML shape you want with the DataContractSerializer.

    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.

    Public Class StackOverflow_10554490
        <CollectionDataContract(Name:="listaActos", Namespace:="http://my.namespace", ItemName:="codigoActo")> _
        Public Class listaActos
            Inherits List(Of String)
        End Class
    
        <DataContract(Name:="Root", Namespace:="http://my.namespace")> _
        Public Class Root
            <DataMember()> _
            Public Property listaActos As listaActos
        End Class
    
        Public Shared Sub Test()
            Dim list As listaActos = New listaActos()
            list.Add("01672")
            list.Add("01673")
            list.Add("01674")
            Dim root = New Root With {.listaActos = list}
            Dim dcs = New DataContractSerializer(GetType(Root))
            Dim ms = New MemoryStream()
            dcs.WriteObject(ms, root)
            Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray()))
        End Sub
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have WCF service running from within a Windows Service. This is working fine
I'm working on a traditional ASP.NET application making WCF service calls. Should I put
I'm working on adding a WCF services layer to my existing .NET application. This
I have following wrapper to help me manage the wcf client lifetime: public class
I’m still working on a WCF solution that should be able to query the
I am working with WCF .NET 3.5 SP1 and have read that one does
I have a working .Net WCF HTTP service. If I put the URL into
I'm working on a WCF service that requires Membership and Profile access. I got
I'm working in a WCF project and we need to reuse some legacy components
I am working on a WCF Service(implemented with Fluent NH), and it is hosted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.