473,372 Members | 1,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Webservice, hashtable?

Hi

I am trying to write a web service. This web service is a "generic
webservice" for our solution - that is, it should be able to return
different data depending on who calls it.

For example, we have 5 possible data items: name, address, company,
creation_date, telephone
(in reality there are 100s of possible data).

The companies who call our webservice can "subscribe" to a subset of this
data: maybe only name & address for example. So when they call the
webservice they receive only name & address back. Another company might
receive only name & telephone number.

(Configuration on the webserver determines what data is relevant for each
company, and they supply their "company id" when they call the web service).

What is a good type of data object to use as the return value? I thought of
a hastable, with key = "name" or "address" for example, and value as the
value. But now I am in doubt if a web service can return hashtables, or if
there might be a better data type anyway.

Thanks for any advice,
Peter

Jan 31 '06 #1
7 9526
I think you will be able to use hashtable for return type as hashtable
implements ISerializable interface. Webservice can use datatypes which
can be serialized. So, you will be able to use hashtable.

Jan 31 '06 #2
Don't you think that returning hashtable will introduce overhead?

Another way may be returning "name-value" collection. where name is
"address", "telephone", etc and value stands for real value of this names.

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"Peter Kirk" <pk@alpha-solutions.dk> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
Hi

I am trying to write a web service. This web service is a "generic
webservice" for our solution - that is, it should be able to return
different data depending on who calls it.

For example, we have 5 possible data items: name, address, company,
creation_date, telephone
(in reality there are 100s of possible data).

The companies who call our webservice can "subscribe" to a subset of this
data: maybe only name & address for example. So when they call the
webservice they receive only name & address back. Another company might
receive only name & telephone number.

(Configuration on the webserver determines what data is relevant for each
company, and they supply their "company id" when they call the web
service).

What is a good type of data object to use as the return value? I thought
of a hastable, with key = "name" or "address" for example, and value as
the value. But now I am in doubt if a web service can return hashtables,
or if there might be a better data type anyway.

Thanks for any advice,
Peter


Jan 31 '06 #3
"Biren Prajapati" <se*********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I think you will be able to use hashtable for return type as hashtable
implements ISerializable interface. Webservice can use datatypes which
can be serialized. So, you will be able to use hashtable.


Would a non-Microsoft client be able to work with a webservice which
returned a hashtable? E.g. would a ColdFusion solution know what to do with
a serialised hashtable?

Just curious...
Jan 31 '06 #4
Hi,

I think you need to rethink on the generic structure and what should be
returned. Returning business entity objects from web methods might be a
better idea. Are you sure that there isn't an business entity that could be
returned (which is common across all companies and could be filterd as per
the company id)?

It's not directly possible to return types that implement IDictionary (they
are not XmlSerializable). Hence it is not directly possible to return a
hashtable. However, you could use a workaround as mentioned here:
http://msmvps.com/blogs/rakeshrajan/.../15/81105.aspx

Note that when you return such custom classes, from web methods, they would
Xml Serialized, which means the response would be in XML. Thus, non-.NET
clients would get an Xml based response, which they would be able to parse.

--
HTH,
Rakesh Rajan
MVP, MCSD
http://www.rakeshrajan.com/
"Peter Kirk" wrote:
Hi

I am trying to write a web service. This web service is a "generic
webservice" for our solution - that is, it should be able to return
different data depending on who calls it.

For example, we have 5 possible data items: name, address, company,
creation_date, telephone
(in reality there are 100s of possible data).

The companies who call our webservice can "subscribe" to a subset of this
data: maybe only name & address for example. So when they call the
webservice they receive only name & address back. Another company might
receive only name & telephone number.

(Configuration on the webserver determines what data is relevant for each
company, and they supply their "company id" when they call the web service).

What is a good type of data object to use as the return value? I thought of
a hastable, with key = "name" or "address" for example, and value as the
value. But now I am in doubt if a web service can return hashtables, or if
there might be a better data type anyway.

Thanks for any advice,
Peter


Jan 31 '06 #5
OOPS!..............I was wrong. We can't return hashtable. As Rakesh
said, it implements IDictionary so, we can't return hashtable from
webmethod.

Jan 31 '06 #6
Peter,
Most webservices of this type define a "YourMethodResult" class that
contains the various data items, and a "YourMethodResults collection" class
of these objects. This is defined in the WSDL contract and is normally
sufficiently "cross platform" to work with any client application.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Peter Kirk" wrote:
Hi

I am trying to write a web service. This web service is a "generic
webservice" for our solution - that is, it should be able to return
different data depending on who calls it.

For example, we have 5 possible data items: name, address, company,
creation_date, telephone
(in reality there are 100s of possible data).

The companies who call our webservice can "subscribe" to a subset of this
data: maybe only name & address for example. So when they call the
webservice they receive only name & address back. Another company might
receive only name & telephone number.

(Configuration on the webserver determines what data is relevant for each
company, and they supply their "company id" when they call the web service).

What is a good type of data object to use as the return value? I thought of
a hastable, with key = "name" or "address" for example, and value as the
value. But now I am in doubt if a web service can return hashtables, or if
there might be a better data type anyway.

Thanks for any advice,
Peter


Jan 31 '06 #7
Check my article on returning custom classes from a web service at
http://www.dalepreston.com/Blog/2005...-from-web.html.

HTH
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Peter Kirk" wrote:
Hi

I am trying to write a web service. This web service is a "generic
webservice" for our solution - that is, it should be able to return
different data depending on who calls it.

For example, we have 5 possible data items: name, address, company,
creation_date, telephone
(in reality there are 100s of possible data).

The companies who call our webservice can "subscribe" to a subset of this
data: maybe only name & address for example. So when they call the
webservice they receive only name & address back. Another company might
receive only name & telephone number.

(Configuration on the webserver determines what data is relevant for each
company, and they supply their "company id" when they call the web service).

What is a good type of data object to use as the return value? I thought of
a hastable, with key = "name" or "address" for example, and value as the
value. But now I am in doubt if a web service can return hashtables, or if
there might be a better data type anyway.

Thanks for any advice,
Peter


Jan 31 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: jerome | last post by:
Hello, I would to use a HashTable in a Webservice (i want that my WebMethod take a hashTable in Parameter) My compilation returns the error message (it's a translation): "Hashtable type is...
1
by: mrkurt | last post by:
I've built a few webservices locally that work just fine. Deployed them to a server and I get the following exception. This exception happens on even the most basic webmethod call. Hitting the...
4
by: WhiskyRomeo | last post by:
I am trying to implement a webservice that returns a HashTable as a result <WebMethod()> Public Function GetAppData() As Hashtable Dim List As New Hashtable 'omitted code Return List End...
1
by: Monster | last post by:
is it possible to manually create and destroy a session object in a webservice? My original client and server were done with SOAP in c++ (isapi dll and mfc/atl). I managed to write an intermediate...
2
by: Sajid | last post by:
Hi, I 've a problem while creating a web method which returns a class object. The actual implementaion of the class using a hashtable which is not serialized by the webservice.. any...
3
by: batista | last post by:
Hello all, I just want to ask one question about the web service test page. The functions which are shown on this test page are not shown in the order in which they are implemented in code....
1
by: Matt Kemmerer | last post by:
I'm trying to return a HashTable froma WebMethod. This fails with a not supported method because HashTable implements IDictionary. What I'm doing right now instead is stuffing my data into a...
0
by: dev | last post by:
I have a website that dynamically instantiates an instance of a class using Reflection from another Assembly. Within that class there is a method that calls a webservice. The webservice is a...
0
by: mr t | last post by:
this is the error I get on the server: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---System.InvalidOperationException: Unable to generate a temporary...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.