Chris

Chris

  • NA
  • 4
  • 0

Web Service XML output

Jun 22 2009 11:58 AM

Hi

I'm starting to play around with Web Services in work now, I have been able to do a simple web services get, edit or insert command.

 

The simple get command returns the below xml (Fig 1)

 

 <classcustomer>

<userId>1</userId>

<username>newnewusername</username>

<userForename>newnewforname</userForename>

<surename>swdxdsd</surename>

</classcustomer>


 

Now I need to do a more complex get command.  The get command needs to be able to have sub nodes and look like the blow xml output (Fig 2)

 

 <classcustomer> 

<userId>1</userId>

<username>newnewusername</username>

<userForename>newnewforname</userForename>

<surename>swdxdsd</surename>

<group>

            <group id='1'>Group1</group>

            <group id='2'>Group2</group>

</group>

</classcustomer>

The Code I use at the moment is simple.  It has the asmx.vb class the uses the below function

 Public Function getcustomer(ByVal id As Integer) As ClassLibrary.classcustomer
        objcust.userId = id        objcust.getCustomer()

 

        Return objcust

    End Function



 

Within the classcustomer class it has public property's surename, userForename, username and userId.

These are set within the getCustomer function wihtin the classcustomer.

This then produces the xml output in Fig 1.

 

<b>How do I add sub nodes within the xml (Fig 2)?

Is there an easy way of altering the node names etc?</b>

 

Thanks