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. C#
  4. Webservice XMLSerialization Question

Webservice XMLSerialization Question

Scheduled Pinned Locked Moved C#
questionxmljsonhelptutorial
3 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    matthias s 0
    wrote on last edited by
    #1

    hi there, I'm currently building a webservice and I've got three questions: is there anything special i need to know about the returned xml? right now, I just return an object (for expample an instance of my Vehicle class) from the WebMethod and this looks fine to me. The second question is, if I use the automated xml serialization with a class which is derived from a base class I defined (e.g. I've got a Car class which derives from the Vehicle class), the properties of the baseclass are not serialized. Properties of the derived class look fine. Why is that? Last but not least: What is the correct way to return an error from a WebMethod if, for example the expected parameters are invalid or an exception occured. thanks a lot!

    /matthias

    I love deadlines. I like the whooshing sound they make as they fly by.
    [Douglas Adams]

    P 1 Reply Last reply
    0
    • M matthias s 0

      hi there, I'm currently building a webservice and I've got three questions: is there anything special i need to know about the returned xml? right now, I just return an object (for expample an instance of my Vehicle class) from the WebMethod and this looks fine to me. The second question is, if I use the automated xml serialization with a class which is derived from a base class I defined (e.g. I've got a Car class which derives from the Vehicle class), the properties of the baseclass are not serialized. Properties of the derived class look fine. Why is that? Last but not least: What is the correct way to return an error from a WebMethod if, for example the expected parameters are invalid or an exception occured. thanks a lot!

      /matthias

      I love deadlines. I like the whooshing sound they make as they fly by.
      [Douglas Adams]

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      The answer to question 1 is that you don't pass the object. Whenever you pass something back from a web-service, you are passing based on a contract. This is important. Basically, you say that your data will look like this, and the SOAP message will contain a representation of that object. 2. Is the base class marked as Serializable as well? 3. It really depends on what you want to achieve. It is perfectly legitimate to throw an exception back from a web-service, but be aware that the exception you get back will not be the exception you threw. (Go on, try it - you'll get a SOAP exception back).

      Deja View - the feeling that you've seen this post before.

      M 1 Reply Last reply
      0
      • P Pete OHanlon

        The answer to question 1 is that you don't pass the object. Whenever you pass something back from a web-service, you are passing based on a contract. This is important. Basically, you say that your data will look like this, and the SOAP message will contain a representation of that object. 2. Is the base class marked as Serializable as well? 3. It really depends on what you want to achieve. It is perfectly legitimate to throw an exception back from a web-service, but be aware that the exception you get back will not be the exception you threw. (Go on, try it - you'll get a SOAP exception back).

        Deja View - the feeling that you've seen this post before.

        M Offline
        M Offline
        matthias s 0
        wrote on last edited by
        #3

        hey pete, thanks for your reply. as for 1: i understand that my object makes up the contract you've mentioned (the structure of the returned xml). So I believe I as long as I don't change my returned object, everything should work fine for my clients. how would you do it? whats the best practise. in the article of chris (http://www.codeproject.com/cs/webservices/myservice.asp[^]), he's doing the same and the documentation doesn't really give me any useful information. as for 2: yes, it has the SerializableAttribute. 3: I'd like to tell my clients, well, if you have no permission, you'll get this type of response, if you passed in invalid arguments, you'll get that type of exception. my english is not so good, I hope you understand what I mean.

        /matthias

        I love deadlines. I like the whooshing sound they make as they fly by.
        [Douglas Adams]

        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