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. Visual Basic
  4. How to pass in class to web service?

How to pass in class to web service?

Scheduled Pinned Locked Moved Visual Basic
data-structuresjsonhelptutorialquestion
10 Posts 3 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.
  • S Offline
    S Offline
    Steve van Niman
    wrote on last edited by
    #1

    Hopefully can give enough information to get pointed in the right direction. Wrote a fairly extensive class and placed in .dll for use in a client application AND my web service. I declare the class as a one dimensional array and then try to pass into the web service; however, when I set client.class = ws.class I get a compilation error indicating that ws.class cannot be converted to client.class. I've tried CType and DirectCast, but both complain of the same thing. Do I need to write a conversion routine in my code to parse each node of the class? There must be an easier way.... (.dll) public class Address private _x as string private _y as string get/set for x and y public sub New() _x="" _y="" end sub end class (client) dim a() as Address ... read data and populate a() dim ws as new webservice.service ws.validate(a()) (web service) public sub validate(byval b() as Address) When I try to run this I get a cannot convert client.a() to webservice.b() even though they implement the .dll with the same class. I don't understand what serialization does for an array, so I'm off to study how that will effect these calls. In the mean time, if someone could point me in the proper directly, it would be greatly appreciated.

    N 1 Reply Last reply
    0
    • S Steve van Niman

      Hopefully can give enough information to get pointed in the right direction. Wrote a fairly extensive class and placed in .dll for use in a client application AND my web service. I declare the class as a one dimensional array and then try to pass into the web service; however, when I set client.class = ws.class I get a compilation error indicating that ws.class cannot be converted to client.class. I've tried CType and DirectCast, but both complain of the same thing. Do I need to write a conversion routine in my code to parse each node of the class? There must be an easier way.... (.dll) public class Address private _x as string private _y as string get/set for x and y public sub New() _x="" _y="" end sub end class (client) dim a() as Address ... read data and populate a() dim ws as new webservice.service ws.validate(a()) (web service) public sub validate(byval b() as Address) When I try to run this I get a cannot convert client.a() to webservice.b() even though they implement the .dll with the same class. I don't understand what serialization does for an array, so I'm off to study how that will effect these calls. In the mean time, if someone could point me in the proper directly, it would be greatly appreciated.

      N Offline
      N Offline
      nlarson11
      wrote on last edited by
      #2

      One way to accomplish this is to put the class in a dll that both sides (client/server) reference.

      'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

      S 1 Reply Last reply
      0
      • N nlarson11

        One way to accomplish this is to put the class in a dll that both sides (client/server) reference.

        'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

        S Offline
        S Offline
        Steve van Niman
        wrote on last edited by
        #3

        I did, both client and web service use the dll. That is what has me perplexed. The message will read module1.class cannot be converted to module2.class.

        N 1 Reply Last reply
        0
        • S Steve van Niman

          I did, both client and web service use the dll. That is what has me perplexed. The message will read module1.class cannot be converted to module2.class.

          N Offline
          N Offline
          nlarson11
          wrote on last edited by
          #4

          If you using the same dll, then why is it saying different names for the class? class1 in the client is the same as class 1 in the service. so just to clarify you have a dll called "mysharedclasses" you webservice has a copy that it references. your client has a copy for it to reference. correct so far?

          'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

          S 1 Reply Last reply
          0
          • N nlarson11

            If you using the same dll, then why is it saying different names for the class? class1 in the client is the same as class 1 in the service. so just to clarify you have a dll called "mysharedclasses" you webservice has a copy that it references. your client has a copy for it to reference. correct so far?

            'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

            S Offline
            S Offline
            Steve van Niman
            wrote on last edited by
            #5

            correct. This is the exact message: Value of type '1-dimensional array of PNDataMap.AddressStructure' cannot be converted to '1-dimensional array of CardProgramNG.ValidateService.AddressStructure' because 'PNDataMap.AddressStructure' is not derived from 'CardProgramNG.ValidateService.AddressStructure'.

            L 1 Reply Last reply
            0
            • S Steve van Niman

              correct. This is the exact message: Value of type '1-dimensional array of PNDataMap.AddressStructure' cannot be converted to '1-dimensional array of CardProgramNG.ValidateService.AddressStructure' because 'PNDataMap.AddressStructure' is not derived from 'CardProgramNG.ValidateService.AddressStructure'.

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Of course PNDataMap.AddressStructure and CardProgramNG.ValidateService.AddressStructure are different types, even their namespaces are different. If they were the same type, the whole namespace mechanism wouldn't make any sense at all. :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

              S 1 Reply Last reply
              0
              • L Luc Pattyn

                Of course PNDataMap.AddressStructure and CardProgramNG.ValidateService.AddressStructure are different types, even their namespaces are different. If they were the same type, the whole namespace mechanism wouldn't make any sense at all. :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                S Offline
                S Offline
                Steve van Niman
                wrote on last edited by
                #7

                which begs the question, how do I pass a class through to a web service?

                L 1 Reply Last reply
                0
                • S Steve van Niman

                  which begs the question, how do I pass a class through to a web service?

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  how do you serialize, and later deserialize some object? by using the same type, i.e. the same assembly, for both operations, whether they are executed by one or more processes. A web service doesn't change that. If one party has set the type, the other party has to agree on using the same type. :)

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                  S 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    how do you serialize, and later deserialize some object? by using the same type, i.e. the same assembly, for both operations, whether they are executed by one or more processes. A web service doesn't change that. If one party has set the type, the other party has to agree on using the same type. :)

                    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                    Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                    S Offline
                    S Offline
                    Steve van Niman
                    wrote on last edited by
                    #9

                    Good question - how do you serialize the object? As stated in the opening question, I have never had to serialize anything - meaning no experience.

                    L 1 Reply Last reply
                    0
                    • S Steve van Niman

                      Good question - how do you serialize the object? As stated in the opening question, I have never had to serialize anything - meaning no experience.

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #10

                      Then start by studying the subject. Read the relevant chapter in your C#/VB.NET book, then go and look for some of those excellent CodeProject articles, and finally apply what you have learned. You're probably too old for spoon feeding anyway. :)

                      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                      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