View Single Post
  #1 (permalink)  
Old 06-24-2009, 4:00 AM
vbcoop vbcoop is offline
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Oct 2008
Age: 27
Posts: 8
Reputation: 0
vbcoop is on a distinguished programming path ahead
Default Web Service XML output

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)

[XML]
<classcustomer>

<userId>1</userId>

<username>newnewusername</username>

<userForename>newnewforname</userForename>

<surename>swdxdsd</surename>

</classcustomer>
[/XML]





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)


[XML]
<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>
[/XML]

The Code I use at the moment is simple. It has the asmx.vb class the uses the below function
[VB]
Public Function getcustomer(ByVal id As Integer) As ClassLibrary.classcustomer
objcust.userId = id
objcust.getCustomer()



Return objcust

End Function

[/VB]




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
Reply With Quote