TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Shrikant Gujar
NA
1
0
Windows Service - WebClient issue
Jun 14 2010 8:55 AM
Firstly, my apologies for posting a question related to windows service into the WinForms category. There is no seperate windows service category and I could not find a way to create a new one. (C# corner guys please take a note)
This is framework 2.0
I have developed a windows service which talks to a server on the cloud which returns a JSON string as a response.
Below is the code sample -
string strServiceUrl = "https://some-url.aspx";
// Add necessary parameter/value pairs to the name/value container.
myNameValueCollection.Add("param1", value1);
myNameValueCollection.Add("param2", value2);
myNameValueCollection.Add("param3", value3 );
myNameValueCollection.Add("json-param4", JSON-value4);
string strResponse = string.Empty;
try
{
// Upload the NameValueCollection.
byte[] responseArray = myWebClient.UploadValues(strServiceUrl, "POST", myNameValueCollection);
// Decode and display the response.
strResponse = Encoding.ASCII.GetString(responseArray);
}
catch(Exception objEx)
{
logText(objEx.Message + "---------" + objEx.StackTrace);
}
I am running these HTTP requests in threads depending on the number of requests added by the user. These are in 100s.
The problem here is that the service gets terminated automatically when the HTTP request is sent and the service manager shows the service as stopped. The service does not throw any exceptions neither does it write anything to the text log file (log written in the catch block)
Note that this code runs smoothly and I get the JSON response when added to a winforms project.
(I am using VS 2005 for development)
Any help on this will be appreciated
TIA
Shrikant
Reply
Answers (
0
)
Associate key seq to application exist
Storing to an ArrayList or HashTable