I am building a web service to pass back a list of (artist) objects. Inside of the artist object there is a list of (album) objects. Inside the Album object there is a list of songs.
SO basically I am building a big parent child tree of music.
My question is, how to I pass this using SOAP?
What is the best method to use.
Right now All I get is
<Artist>
<Name>string</Name>
<Albums>
<AlbumName>string</AlbumName>
<Album xsi:nil="true" />
<Album xsi:nil="true" />
</Albums>
<Albums>
<AlbumName>string</AlbumName>
<Album xsi:nil="true" />
<Album xsi:nil="true" />
</Albums>
</Artist>
It breaks down at albums but it shows two albums which I have stored.
Any Suggestions would be appreciated!
The good news is that a .NET web service will take care of the XML for you. All you have to do is declare the return type as
List<Artist>
or similar. The web service will take care of serializing your objects into XML for you. It's not clear if you were rolling your own XML.The XML you've pasted looks like it came from the WSDL.
Run your project in Visual Studio, and browse to the web service .asmx page. You'll find something like this.
Click that button to have your method run.
Perhaps try this simple test WebMethod if your own isn't working as you expect: The result will be this XML doc.
Something like this :
NOTE : This is just to show how to make your objects serialize. Modify it to use properties instead of public fields, etc...
You need just to implement WCF service and use
List<Artist>
.