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
Vikram N
NA
66
19.5k
Unable to display the contents of queue in MSMQ via webapp.
Sep 25 2013 11:43 PM
Hello,
Below is the code I have written to display the contents of an MSMQ queue. It works fine in case of winforms. But When i create a web application, Though the queue has some data, Nothing is displayed.
Can u help me..?
Thanks in advance.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Messaging;
using System.Text;
using System.Windows.Forms;
namespace MSMQWebService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
string QueueName = ".\\Private$\\q1";
[WebMethod]
public string DisplayMessage()
{
bool NoMessage = true;
MessageQueue Q1 = new MessageQueue(QueueName);
System.Messaging.Message[] AllMessages = Q1.GetAllMessages();
foreach (System.Messaging.Message theMessage in AllMessages)
{
NoMessage = false;
byte[] data = new byte[1024];
theMessage.BodyStream.Read(data, 0, 1024);
string strMessage = ASCIIEncoding.ASCII.GetString(data);
Console.WriteLine(strMessage);
}
if (NoMessage)
{
MessageBox.Show("Message Queue is Empty");
}
return "Success";
}
}
Reply
Answers (
30
)
Deleted File Recovery
Save and Retrieve images using web service C#