Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. Help with deriving DataContract from Plain Old Xml Service

Help with deriving DataContract from Plain Old Xml Service

Scheduled Pinned Locked Moved WCF and WF
csharpwcfcomdata-structuresxml
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    duncanmhor
    wrote on last edited by
    #1

    Hi all, having a bit of trouble with setting up a WCF client to consume a POX service (Truvevo video) The service returns an XML doc like this:

    <Response>
    <VideoSet>
    <totalResultsAvailable>
    integer value
    </totalResultsAvailable>
    <totalResultsReturned>
    integer value
    </totalResultsReturned>
    <firstResultPosition>
    integer value
    </firstResultPosition>
    <Video>
    Nested XML elements
    </Video>
    <Video>
    Nested XML elements
    </Video>
    <Video>
    Nested XML elements
    </Video>
    <VideoSet>
    </Response>

    In order to consume this service, I set up a WCF client that has this

    [DataContract(Namespace = "http://xml.searchvideo.com")]
    public class Response
    {
    ///
    /// Within the response we find the VideoSet tag, which
    /// contains an array of Videos.

        //\[DataMember(Name = "VideoSet")\]
        //public Video\[\] TheVideoSet;
    
        \[DataMember(Name = "VideoSet")\]
        public VideoSet TheVideoSet;
    }
    

    [DataContract(Namespace = "http://xml.searchvideo.com")]
    public class VideoSet
    {
    [DataMember(Name = "totalResultsAvailable")]
    public int TotalResultsAvailable;

        \[DataMember(Name="totalResultsReturned")\]
        public int TotalResultsReturned;
    
        \[DataMember(Name="firstResultPosition")\]
        public int FirstResultPositon;
    
        \[DataMember(Name="Video")\]
        public Video\[\] TheVideos   
    
    }
    

    If I run this code, I have values assigned for the three integer types, but the array is null. If I change the code in the Response class and simply add the Videoset DataMember attribute directly to the array of Video objects (these work), the array is populated, but obviously I don't get the results info. Anyone have any ideas?

    "You're very clever, young man, very clever," said the old lady. "But it's turtles all the way down!"

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups