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

Discussion in 'ASP .Net Web Services' started by Matty J, Apr 20, 2008.

  1. Matty J

    Matty J Guest

    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
     
    Matty J, Apr 20, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stanimir Stamenkov
    Replies:
    2
    Views:
    772
    Stanimir Stamenkov
    Oct 25, 2005
  2. Robert Mark Bram
    Replies:
    0
    Views:
    706
    Robert Mark Bram
    Feb 4, 2007
  3. Simon
    Replies:
    0
    Views:
    1,052
    Simon
    Oct 13, 2009
  4. Cindy Lee
    Replies:
    1
    Views:
    2,212
    Mr. Arnold
    Mar 19, 2010
  5. Mike Dearman
    Replies:
    1
    Views:
    207
    Mike Dearman
    Jun 23, 2004
Loading...

Share This Page