Get hold of properties in webservice class

Hi,

I'm working with a webservice with different classes in it.

A class can look like this for example:
    Public Class TekniskInformation
        Implements IExtensibleDataObject, INotifyPropertyChanged

        Public Sub New()

        Public Property ExtensionData As ExtensionDataObject
        <DataMember>
        Public Property Fordonsidentifikation As Fordonsidentifikation
        <DataMember>
        Public Property VardenPerDrivmedel As Drivmedel()
        <DataMember>

        Public Event PropertyChanged As PropertyChangedEventHandler

        Protected Sub RaisePropertyChanged(propertyName As String)
    End Class

Open in new window


The class of Fordonsidentifikation then looks like this:
  Public Class Fordonsidentifikation
        Implements IExtensibleDataObject, INotifyPropertyChanged

        Public Sub New()

        <DataMember>
        Public Property FordonskategoriEU As String
        <DataMember>
        Public Property ModellNr As Integer?
        <DataMember>
        Public Property Handelsbeteckning As String
        <DataMember>
        Public Property GruppNr As Integer?
        <DataMember>
        Public Property Fordonsslagskod As Integer?
        <DataMember>
        Public Property Fordonsslagsklass As String
        <DataMember>
        Public Property Fordonsslag As String
        <DataMember>
        Public Property RegNr As String
        <DataMember>
        Public Property Fordonsar As String
        <DataMember>
        Public Property Farg As String
        <DataMember>
        Public Property Fabrikatskod As String
        <DataMember>
        Public Property FabrikatTyp As String
        <DataMember>
        Public Property ChassiNr As String
        <DataMember>
        Public Property Bussklass As String
        <DataMember>
        Public Property Arsmodell As Integer?
        Public Property ExtensionData As ExtensionDataObject
        <DataMember>
        Public Property MotorNr As String
        <DataMember>
        Public Property PersRegNr As String

        Public Event PropertyChanged As PropertyChangedEventHandler

        Protected Sub RaisePropertyChanged(propertyName As String)
    End Class

Open in new window

So to get data from that class I just apply this code:
 Dim fordon As Fordonsidentifikation = grundInfo.Fordonsidentifikation
sb.Append("Personregnr: " & fordon.PersRegNr & "<br>")
            sb.Append("Fordinsslag: " & fordon.Fordonsslag & "<br>")

Open in new window


No problem there. But then we come to the second class, Drivmedel. The class of that looks like this:

   Public Class Drivmedel
        Implements IExtensibleDataObject, INotifyPropertyChanged

        Public Sub New()

        <DataMember>
        Public Property EnhetEmissioner As String
        <DataMember>
        Public Property HCNOX3 As Integer?
        <DataMember>
        Public Property HCTHC As Integer?
        <DataMember>
        Public Property HCTHCplusNOX As Integer?
        <DataMember>
        Public Property Kravtillhor As String
        <DataMember>
        Public Property LjudnivaKorning As Integer?
        <DataMember>
        Public Property LjudnivaStilla As Integer?
        <DataMember>
        Public Property MaxHastighet As Integer?
        <DataMember>
        Public Property Motoreffekt As Integer?
        <DataMember>
        Public Property NMHC As Integer?
        <DataMember>
        Public Property NMHC3 As Integer?
        <DataMember>
        Public Property NOX As Integer?
        <DataMember>
        Public Property NOX2 As Integer?
        <DataMember>
        Public Property NOX3 As Integer?
        <DataMember>
        Public Property Partiklar As Integer?
        <DataMember>
        Public Property Partiklar2 As Integer?
        <DataMember>
        Public Property Partiklar3 As Integer?
        <DataMember>
        Public Property Roktathet As Integer?
        <DataMember>
        Public Property THC As Integer?
        <DataMember>
        Public Property THC3 As Integer?
        <DataMember>
        Public Property HC As Integer?
        <DataMember>
        Public Property VarvtalVidLjudniva As Integer?
        <DataMember>
        Public Property EnhetBransleforbr As String
        <DataMember>
        Public Property ElenergiforbrukViktad_Wh_km As Integer?
        Public Property ExtensionData As ExtensionDataObject
        <DataMember>
        Public Property Absorptionskoefficient As Integer?
        <DataMember>
        Public Property AvgasDirektiv As String
        <DataMember>
        Public Property Avgaskontrollspecifikation As String
        <DataMember>
        Public Property BransleforbrBlandad As Integer?
        <DataMember>
        Public Property BransleforbrLandsvag As Integer?
        <DataMember>
        Public Property BransleforbrStad As Integer?
        <DataMember>
        Public Property C0 As Integer?
        <DataMember>
        Public Property CH4 As Integer?
        <DataMember>
        Public Property CO2Blandad As Integer?
        <DataMember>
        Public Property CO2Landsvag As Integer?
        <DataMember>
        Public Property CO2Stad As Integer?
        <DataMember>
        Public Property CO3 As Integer?
        <DataMember>
        Public Property COvarde As Integer?
        <DataMember>
        Public Property DrivmedelsId As Integer?
        <DataMember>
        Public Property Drivmedelsnamn As String
        <DataMember>
        Public Property Effektenhet As String
        <DataMember>
        Public Property ElektriskRackviddKm As Integer?
        <DataMember>
        Public Property ElenergiforbrukBland_Wh_km As Integer?
        <DataMember>
        Public Property Tankvolym As Integer?
        <DataMember>
        Public Property Varvtal As Integer?

        Public Event PropertyChanged As PropertyChangedEventHandler

        Protected Sub RaisePropertyChanged(propertyName As String)
    End Class

Open in new window


But this is another kind of property so I can not get hold of the data in the same way. I can of course get hold of the properties like this:
 Dim drivmedel As New Drivmedel

            sb2.Append("Drivmedelsid: " & drivmedel.DrivmedelsId & "<br>")
            sb2.Append("Drivmedelsnamn: " & drivmedel.Drivmedelsnamn & "<br>")

Open in new window


But there is of course no data there, and I can't figure out how to get hold of it (probably it's very easy, but right now I'm blank). How can I get hold of the data in the class drivmedel with the property VardenPerDrivmedel?

Thanks for help!

Peter
Peter NordbergIT ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

louisfrCommented:
VardenPerDrivmedel's type is not Drivmedel. It's an array of Drivmedel. You have to loop over it
For Each drivmedel In grundInfo.VardenPerDrivmedel
    sb2.Append("Drivmedel:")
    sb2.Append("    Drivmedelsid: " & drivmedel.DrivmedelsId & "<br>")
    sb2.Append("    Drivmedelsnamn: " & drivmedel.Drivmedelsnamn & "<br>")
End For

Open in new window

or you have to access a specific item
Dim drivmedel as Drivmedel = grundInfo.VardenPerDrivmedel(0)
sb2.Append("    Drivmedelsid: " & drivmedel.DrivmedelsId & "<br>")
sb2.Append("    Drivmedelsnamn: " & drivmedel.Drivmedelsnamn & "<br>")

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Peter NordbergIT ManagerAuthor Commented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.