WCF and RESTful web service that outputs complex XML type (.NET 3.5)

M

Matty J

Hi.
I'm trying to create a .NET 3.5 WCF web service .svc with a XML schema
that somewhat complex, which I'm new to.

The schema I want is, in a simplified form for example puposes,
similar to the following:

<root>
<productoffer>
<product>
<name>Name</name>
<desc>Description</desc>
[more nodes here]
</product>
<offers>
<store-offer number="1">
<store-name>Name</store-name>
<offer-desc>Description of store offer on product</offer-desc>
[more nodes here]
</store-offer>
<store-offer number="2">
<store-name>Name 2</store-name>
<offer-desc>Description 2 of store offer on product</offer-
desc>
[more nodes here]
</store-offer>
</offers>
</productoffer>
</root>

The product info and store offers are to come from a database. My
intention is to start by creating objects / types for each of
<product> and <store-offer>. Then presumably I'll need to create a
type for <offers>, which contains <store-offer> types. Then presumably
I'll need to create a type for <product-offer> type which contains
<product> and <offers> types.

I'm not sure if I then need to create a type for <root> or not,
although that's not the main reason for my question.

From what I understand, I need to then create a servicecontract
interface, with operation contracts set to 'WebGet's and with calls to
functions returning the "summary" type that I want output as XML.

I think I also need to serialise my types - is that correct?

Note that the full version of the XML schema that I want has a few
attributes that are kinda hard to change to elements, so I'm not sure
using the svcutil.exe utility to create the type for my service will
work. I've played with it, but I'd need to add some attributes, if
that's possible.

So what the main thing I'm wondering is, and it's possibly because I'm
missing something fundamental, how do I instanciate types that contain
sub-types...? I guess I instanciate, in order, an instance of a type
for product, several for store-offers, one for offers to then wrap the
store-offers, then one productoffer to wrap the product and store-
offers, then one root to wrap the productoffer (maybe this last step
is not needed).

Maybe I've answered my own question here by typing out my thoughts, if
anyone has an corrections or can point out errors, it would be greatly
appreciated.

Cheers
Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top