Custom types

N

Nikolay Petrov

Which is the best and convenient way to send/retrun custom types to/from Web
Service? Serialization?

The web service is not to be public accessible, it's a part of n-tier
application.

TIA
 
C

Cor Ligthert

Nikolay,

In my opinion it is just using it, most serialization is done for you by
VSNet. When not as with an arraylist you have to decide what you do, however
it will always be serialized by VSNet to XML.

Just my thought,

Cor

"Nikolay Petrov"
 
H

Hans Kesting

Cor said:
Nikolay,

In my opinion it is just using it, most serialization is done for you
by VSNet. When not as with an arraylist you have to decide what you
do, however it will always be serialized by VSNet to XML.

Just my thought,

Cor

I have tried returning some custom type from a webservice. Some data
did get through, but in a *generated* class that only has *some* resemblance
to the original type. Do you know if there is some way to have the calling
side use the same type (apart from creating that "by hand" and copying
all values)?

Hans Kesting
 
N

Nikolay Petrov

What I need mostly is to return data with different types as strings,
integers an so, currently I don't need to return classes or something like
them.

Is it appropriate to use hash tables?
 
H

Hans Kesting

Nikolay said:
What I need mostly is to return data with different types as strings,
integers an so, currently I don't need to return classes or something
like them.

Is it appropriate to use hash tables?

Do you mean you want to have a webservice method that returns an int
(and another that returns a string)? That is easy, just declare the method in
the asmx as returning an int. When you call this you will get an integer back.
For these basic types serialization issues are handled automatically by the
system, you don't need to do anything special.

Hans Kesting
 
C

Cor Ligthert

Nikolay,

When you need a table, than in my opinion is the most easy one to use the
dataset.
Everything is than done for you.

I hope this helps,

Cor

"Nikolay Petrov"
 
N

Nikolay Petrov

No I need to return both in one call.

As you would declare structure

Structure Type
Dim Digit as Integer
Dim Text as String
End Structure

I want to return something similar, no need to be structure just I need to
return strings, integers, booleans as a whole.
 
H

Hans Kesting

Nikolay said:
No I need to return both in one call.

As you would declare structure

Structure Type
Dim Digit as Integer
Dim Text as String
End Structure

I want to return something similar, no need to be structure just I
need to return strings, integers, booleans as a whole.

So you want to return a single value, but you can't declare as (for ex.) "string"
because it also can be int, bool, ...
Would it work to just declare it as "object"? The receiving side should
then check the type ("is bool", "is int", .. (in C# syntax) ) to handle it further.

Hans Kesting
 
N

Nikolay Petrov

This sounds more convenient
But maybe DataSet is more easy to use in my scenario
Any advantages/disadvantages of using Dataset instead or serialized data, in
my case?
 
K

Kevin Spencer

Why use a class? Structures are serializable, and don't have the overhead
associated with classes. We have numerous WebMethods that return structures,
and even arrays of structures.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
C

Cor Ligthert

Kevin,
Why use a class? Structures are serializable, and don't have the overhead
associated with classes. We have numerous WebMethods that return
structures,
and even arrays of structures.
This contribution sounds for me like from a kid from 4.

Daddy why must I drink limonade and not whiskey?
My friend is allowed to drink whiskey and he says that is better.

Cor
 
K

Kevin Spencer

Apparently, you are not concerned with performance. I guess only us
4-year-olds care about such childish concerns.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
C

Cor Ligthert

Why use a class? Structures are serializable, and don't have the
Apparently, you are not concerned with performance. I guess only us
4-year-olds care about such childish concerns.
This sounds again as from kids from 4-years-olds, who say that cars with a
structure of a Ford are much faster than those from a class as Ferrari.
There are more kids whose daddy has a Ford, than whose has a Ferrari;
however, that says nothing about the performance.

Grown up tell why a Ford is faster than a Ferrari when they want to discuss
that, they don't type something like this above or words as "the overhead
involved", without telling what overhead.

Cor
 
C

Cor Ligthert

Nikolay,

I would not know why, in my opinion holds a serialized dataset almost the
same node information as any other type when it is XML serialized. (When we
are talking about collections of course, otherwise I think that the answers
from Hans and me are the same)

Cor
 
H

Herfried K. Wagner [MVP]

Cor Ligthert said:
This sounds again as from kids from 4-years-olds, who say that cars with a
structure of a Ford are much faster than those from a class as Ferrari.
There are more kids whose daddy has a Ford, than whose has a Ferrari;
however, that says nothing about the performance.

Comparing things with cars is never a good idea(TM).
 
K

Kevin Spencer

Grown up tell why a Ford is faster than a Ferrari when they want to
discuss

Grown ups don't behave like you do, kid. When you're grown up, you'll
understand. Until then, you might try to act like one.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
C

Cor Ligthert

Kevin,
Grown ups don't behave like you do, kid. When you're grown up, you'll
understand. Until then, you might try to act like one.

As I wrote in the dotnet.general newsgroup too somebody else where is a long
spamming thread, when somebody looses a discussion they starts to give the
winner names.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top