How to pass in class to web service?
-
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.
-
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.
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
-
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
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.
-
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.
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
-
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
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'.
-
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'.
Of course
PNDataMap.AddressStructure
andCardProgramNG.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.
-
Of course
PNDataMap.AddressStructure
andCardProgramNG.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.
which begs the question, how do I pass a class through to a web service?
-
which begs the question, how do I pass a class through to a web service?
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.
-
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.
Good question - how do you serialize the object? As stated in the opening question, I have never had to serialize anything - meaning no experience.
-
Good question - how do you serialize the object? As stated in the opening question, I have never had to serialize anything - meaning no experience.
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.