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. XML Web Services question

XML Web Services question

Scheduled Pinned Locked Moved C#
wcfquestionxml
4 Posts 4 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.
  • C Offline
    C Offline
    Chen Venkataraman
    wrote on last edited by
    #1

    After playing with XML Web Services a little bit, it looks like all the data members of any custom object that need to be serialized across should be marked as public. This seems so non O-Oish or is this a limitation of the WSDL that gets generated automatically that it only supports public data members. For e.g. [Serializable] public class SomeData { public string _id; // if this is marked private, WSDL ignores it public string Id { get { return _id; } } } Is there a way around this? Chen Venkataraman

    A H M 3 Replies Last reply
    0
    • C Chen Venkataraman

      After playing with XML Web Services a little bit, it looks like all the data members of any custom object that need to be serialized across should be marked as public. This seems so non O-Oish or is this a limitation of the WSDL that gets generated automatically that it only supports public data members. For e.g. [Serializable] public class SomeData { public string _id; // if this is marked private, WSDL ignores it public string Id { get { return _id; } } } Is there a way around this? Chen Venkataraman

      A Offline
      A Offline
      Andy Brummer
      wrote on last edited by
      #2

      It's due to the way xml serialization works. It doesn't actually remote the object like you would think. What happens is that wsdl.exe creates a class on the client that is serialziation comatible with your class, with none of the methods. It will just be a simple struct with data fields only.

      1 Reply Last reply
      0
      • C Chen Venkataraman

        After playing with XML Web Services a little bit, it looks like all the data members of any custom object that need to be serialized across should be marked as public. This seems so non O-Oish or is this a limitation of the WSDL that gets generated automatically that it only supports public data members. For e.g. [Serializable] public class SomeData { public string _id; // if this is marked private, WSDL ignores it public string Id { get { return _id; } } } Is there a way around this? Chen Venkataraman

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        Only the property needs to be public. Your field that stores the actual value should be marked private. You want WSDL to ignore it and only pay attention to the public property. After all, why include values for both _id and Id, which actually are the same object? If you want more control over the WSDL that's generated, see the attributes in the System.Xml.Serialization namespace, as well as those in the System.Web.Services and System.Web.Services.Protocols namespaces. There is plenty of documentation about these in the .NET Framework SDK. Besides, remember that the Web Service is just another class that code can call via a proxy. Classes can only access public members of other classes unless they're derived from that class. This is how code access is supposed to work.

        Microsoft MVP, Visual C# My Articles

        1 Reply Last reply
        0
        • C Chen Venkataraman

          After playing with XML Web Services a little bit, it looks like all the data members of any custom object that need to be serialized across should be marked as public. This seems so non O-Oish or is this a limitation of the WSDL that gets generated automatically that it only supports public data members. For e.g. [Serializable] public class SomeData { public string _id; // if this is marked private, WSDL ignores it public string Id { get { return _id; } } } Is there a way around this? Chen Venkataraman

          M Offline
          M Offline
          Michael Potter
          wrote on last edited by
          #4

          XML Serialization only serializes public data. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpovrSerializingObjects.asp Chen Venkataraman wrote: Is there a way around this? Yes http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemRuntimeSerializationISerializableClassTopic.asp Or you can do a binary serialization to a MemoryStream and send it as a byte array. I have used this method successfully with an intermediate compression/encryption pass.

          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