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. Web Service Proxy Problem!

Web Service Proxy Problem!

Scheduled Pinned Locked Moved C#
helpbusinessjsontutorialquestion
4 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
    Mehdi Mousavi
    wrote on last edited by
    #1

    Hi folks, Consider a MyEntity class that's being marked as SerializableAttribute. The object is exposed to the outer world through the following web method: [WebMethod()] [SoapHeader("Credentials")] [SoapDocumentMethod(Use=SoapBindingUse.Encoded)] public MyEntity GetMyEntity() { //get the entity and return the object. } Well, I've to mark the web method with SoapDocumentMethodAttribute, or else, the XMLSerializer doesn't have any idea of how to serialize/deserialize the object. I've also altered the reference.cs file (the proxy file generated for the web service automatically) so that it will uses my business_objects.dll to handle objects, the file that hosts the MyEntity class. The problem is that whenever the GetMyEntity() function is called, the service proxy tries to construct the object using the properties exposed on MyEntity class, using the default constructor of the class. How am I supposed to instruct the proxy to use the class constructors to get the job done? How am I supposed to control the serialization/deserialization process of the entities? Please keep in mind that the MyEntity class uses circular references, and therefore, the XMLSerilizer or Literal encoding *cannot be used* to handle the issue. Any help would be highly appreciated, TIA, Mehdi

    A 1 Reply Last reply
    0
    • M Mehdi Mousavi

      Hi folks, Consider a MyEntity class that's being marked as SerializableAttribute. The object is exposed to the outer world through the following web method: [WebMethod()] [SoapHeader("Credentials")] [SoapDocumentMethod(Use=SoapBindingUse.Encoded)] public MyEntity GetMyEntity() { //get the entity and return the object. } Well, I've to mark the web method with SoapDocumentMethodAttribute, or else, the XMLSerializer doesn't have any idea of how to serialize/deserialize the object. I've also altered the reference.cs file (the proxy file generated for the web service automatically) so that it will uses my business_objects.dll to handle objects, the file that hosts the MyEntity class. The problem is that whenever the GetMyEntity() function is called, the service proxy tries to construct the object using the properties exposed on MyEntity class, using the default constructor of the class. How am I supposed to instruct the proxy to use the class constructors to get the job done? How am I supposed to control the serialization/deserialization process of the entities? Please keep in mind that the MyEntity class uses circular references, and therefore, the XMLSerilizer or Literal encoding *cannot be used* to handle the issue. Any help would be highly appreciated, TIA, Mehdi

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

      Keep in mind there are 2 classes involved in this case. On the server your MyEntity class exists as you have defined it. On the client there is a MyEntity class created when you generate the WebReference this class is a simple data class that just has public fields defined which match the public properties of the class defined on the server. When you write a web service, it is really just a collection of static methods which return simple data objects.

      I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

      M 1 Reply Last reply
      0
      • A Andy Brummer

        Keep in mind there are 2 classes involved in this case. On the server your MyEntity class exists as you have defined it. On the client there is a MyEntity class created when you generate the WebReference this class is a simple data class that just has public fields defined which match the public properties of the class defined on the server. When you write a web service, it is really just a collection of static methods which return simple data objects.

        I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

        M Offline
        M Offline
        Mehdi Mousavi
        wrote on last edited by
        #3

        I think you missed the part that I said: "I've also altered the reference.cs file (the proxy file generated for the web service automatically) so that it will use my business_objects.dll to handle objects, the file that hosts the MyEntity class." This means that those classes you've mentioned do not exist any more. It now uses my business_objects.dll on the client (and server)... So what? What am I supposed to do to handle the Serializing/Deserializing the objects as needed? TIA, Mehdi

        A 1 Reply Last reply
        0
        • M Mehdi Mousavi

          I think you missed the part that I said: "I've also altered the reference.cs file (the proxy file generated for the web service automatically) so that it will use my business_objects.dll to handle objects, the file that hosts the MyEntity class." This means that those classes you've mentioned do not exist any more. It now uses my business_objects.dll on the client (and server)... So what? What am I supposed to do to handle the Serializing/Deserializing the objects as needed? TIA, Mehdi

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

          Mehdi Mousavi wrote:

          What am I supposed to do to handle the Serializing/Deserializing the objects as needed?

          You aren't. The proxy classes are designed to just instantiate a data class they weren't intended to do what you are trying to do. I'd write a wrapper around the proxy class that converts between your objects and the proxy object data objects. That would probably get you the closest to what you are trying to accomplish.

          Using the GridView is like trying to explain to someone else how to move a third person's hands in order to tie your shoelaces for you. -Chris Maunder

          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