473,322 Members | 1,473 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,322 software developers and data experts.

XML web service and Hashtable problem

I am having a problem with Hashtable used in XML web server.
I have a WebMethod where clients get registered and added into hashtable.
Later, I call another web method which has client ID as parameter. I first
thought I was doing something wrong with keys, but now i found out the
Hashtable is empty (Count property returns 0)

Code:

[WebMethod()]
public void RegisterClient(int id)
{
if(!this.clients.ContainsKey(id))
{
this.clients.Add(id, new ClientWrapper(id));
return;
}
throw new Exception("ERROR");
}

[WebMethod()]
public void Log(string message, int clientID)
{
if(this.clients.ContainsKey(clientID))
{
ClientWrapper w = (ClientWrapper)this.clients[clientID];
w.Log(message);
return;
}
else
{
throw new Exception("Client not found while logging: " + clientID + "
Client count is " + this.clients.Count) ; //I see from here that the
Hashtable does not contain that key and Count is zero!!
}
}

I am sure that method RegisterClient is called before method Log is called.
I am not able to debug because VS says symbols were not loaded and Debug
class helps me neither because I am getting errors like "Process can not
access the file because it is used by another process" when trying to use
Debug.WriteLine()

Any help would be greatly appreciated.
Nov 16 '05 #1
2 3840
Marek,

So you're populating the hashtable (RegisterClient()), which is a data
member of web service class, then querying it ( Log() )?
This won't work on it's own because the object is not persistent. Web
services are meant to be a way to interface with something else, ( eg.
Database ).

You'd typically have RegisterClient add a client to a database (or file
etc), then return back the unique id, rather than expecting the caller to
provide it. Then when the Log method is called, you'd first create and
populate an instance of your ClientWrapper class by reading from your data
source (database or file), then perform your "Log".

If you need more help, perhaps provide more details into the general purpose
of the web service.

thanks.

Daniel.
"Marek" <ma********@hotmail.com> wrote in message
news:%2********************@TK2MSFTNGP14.phx.gbl.. .
I am having a problem with Hashtable used in XML web server.
I have a WebMethod where clients get registered and added into hashtable.
Later, I call another web method which has client ID as parameter. I first
thought I was doing something wrong with keys, but now i found out the
Hashtable is empty (Count property returns 0)

Code:

[WebMethod()]
public void RegisterClient(int id)
{
if(!this.clients.ContainsKey(id))
{
this.clients.Add(id, new ClientWrapper(id));
return;
}
throw new Exception("ERROR");
}

[WebMethod()]
public void Log(string message, int clientID)
{
if(this.clients.ContainsKey(clientID))
{
ClientWrapper w = (ClientWrapper)this.clients[clientID];
w.Log(message);
return;
}
else
{
throw new Exception("Client not found while logging: " + clientID + "
Client count is " + this.clients.Count) ; //I see from here that the
Hashtable does not contain that key and Count is zero!!
}
}

I am sure that method RegisterClient is called before method Log is
called.
I am not able to debug because VS says symbols were not loaded and Debug
class helps me neither because I am getting errors like "Process can not
access the file because it is used by another process" when trying to use
Debug.WriteLine()

Any help would be greatly appreciated.

Nov 16 '05 #2
Dan,
thank you very much for your reply.
I didn't know web service classes are non-persistent, I am just beginning
with web services. Thanks for clarification.

Sincerely,
Marek

"Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk> wrote in message
news:OQ****************@TK2MSFTNGP10.phx.gbl...
Marek,

So you're populating the hashtable (RegisterClient()), which is a data
member of web service class, then querying it ( Log() )?
This won't work on it's own because the object is not persistent. Web
services are meant to be a way to interface with something else, ( eg.
Database ).

You'd typically have RegisterClient add a client to a database (or file
etc), then return back the unique id, rather than expecting the caller to
provide it. Then when the Log method is called, you'd first create and
populate an instance of your ClientWrapper class by reading from your data
source (database or file), then perform your "Log".

If you need more help, perhaps provide more details into the general purpose of the web service.

thanks.

Daniel.
"Marek" <ma********@hotmail.com> wrote in message
news:%2********************@TK2MSFTNGP14.phx.gbl.. .
I am having a problem with Hashtable used in XML web server.
I have a WebMethod where clients get registered and added into hashtable. Later, I call another web method which has client ID as parameter. I first thought I was doing something wrong with keys, but now i found out the
Hashtable is empty (Count property returns 0)

Code:

[WebMethod()]
public void RegisterClient(int id)
{
if(!this.clients.ContainsKey(id))
{
this.clients.Add(id, new ClientWrapper(id));
return;
}
throw new Exception("ERROR");
}

[WebMethod()]
public void Log(string message, int clientID)
{
if(this.clients.ContainsKey(clientID))
{
ClientWrapper w = (ClientWrapper)this.clients[clientID];
w.Log(message);
return;
}
else
{
throw new Exception("Client not found while logging: " + clientID + "
Client count is " + this.clients.Count) ; //I see from here that the
Hashtable does not contain that key and Count is zero!!
}
}

I am sure that method RegisterClient is called before method Log is
called.
I am not able to debug because VS says symbols were not loaded and Debug
class helps me neither because I am getting errors like "Process can not
access the file because it is used by another process" when trying to use Debug.WriteLine()

Any help would be greatly appreciated.


Nov 16 '05 #3

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

Similar topics

5
by: francois | last post by:
First of all I would to to apologize for resending this post again but I feel like my last post as been spoiled Here I go for my problem: Hi, I have a webservice that I am using and I would...
33
by: Ken | last post by:
I have a C# Program where multiple threads will operate on a same Hashtable. This Hashtable is synchronized by using Hashtable.Synchronized(myHashtable) method, so no further Lock statements are...
7
by: Kalyani | last post by:
Hi, I have a web service method which needs to return a hashtable.But it gives errror as, The type System.Collections.Hashtable is not supported because it implements IDictionary. Is there...
0
by: Anonieko Ramos | last post by:
Self Installing Service Enter a topic name to show or a new topic name to create; then press Enter .. Start by writing a service. This involves deriving a class from...
3
by: danavni | last post by:
i need to build a service that will accept incoming TCP/IP connections. the service should act like a "HUB" where on one side clients connect to it and stay connected for as long as they like and...
7
by: SevDer | last post by:
Hi We have a static hashtable that is located in another tier in our n-tiered web application. And we are storing big but not huge objects in this hashtable and the key to the objects is...
6
by: placek | last post by:
Hi all. I would like to create two web services: - The first one - ImportData - should take as an input parameter a XML document and return an integer saying if passed XML document was valid...
1
by: =?Utf-8?B?QXZp?= | last post by:
Hi I have an interesting issue, I hope someone can shead light on: I have a 2 server "web farm" with a web app that produces image files. To ensure synchronization of content on both machines,...
1
by: Purohit.Amit | last post by:
Hi, I have a AXIS Webservice that is expecting a hashtable as an input. I add the web reference to the webservice and the WSDL that is generated contains the below schema for the HashTable. When I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.