Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MQSendMessage Missing Body

Status
Not open for further replies.

jmsides

Programmer
Joined
May 30, 2003
Messages
2
Location
US
When I send a message the message that is placed on the Q has no Body, or if it does I cannot access it.

SendMSMQMessage (L"DIRECT=TCP:192.168.246.241\\private$\\sefaxmodem",L"FaxModemEvent",eventMsg);

The value of eventMessage is - eventMsg = 0x0042a388 "<?xml version="1.0"?><faxModemEvent faxDevice="COM10" eventId="13" pageNumber="1" succeeded="1" Fax Code="0" Line Code="0"> <eventMessage><![CDATA[Completed]]></eventMessage></faxModemEvent>"

void
SendMSMQMessage(LPWSTR QueueName, LPWSTR Label, char* Body) //from faxengine
{
MQMSGPROPS Message;
MSGPROPID PropID[3];
MQPROPVARIANT PropVars[3];
HRESULT hrStatus[3];

PropID[0] = PROPID_M_LABEL;
PropVariantInit(&PropVars[0]);
PropVars[0].vt = VT_LPWSTR;
PropVars[0].pwszVal = Label;

PropID[1] = PROPID_M_BODY;
PropVars[1].vt = VT_VECTOR | VT_UI1;
PropVars[1].caub.pElems = (LPBYTE) Body;
PropVars[1].caub.cElems = (ULONG) sizeof(CHAR)*strlen(Body);

PropID[2] = PROPID_M_BODY_TYPE;
PropVars[2].vt = VT_UI4;
PropVars[2].ulVal = VT_EMPTY; //VT_I1;

Message.cProp = 3;
Message.aPropID = PropID;
Message.aPropVar = PropVars;
Message.aStatus = hrStatus;

QUEUEHANDLE DestQueue;
//
HRESULT hr;

hr = MQOpenQueue(QueueName,MQ_SEND_ACCESS,MQ_DENY_NONE, &DestQueue);
//
hr = MQSendMessage(DestQueue,&Message,MQ_NO_TRANSACTION);
hr = MQCloseQueue(DestQueue);
//
}

hr is OK in all cases.

I am not a C++ programmer so any help I can get is greatly appreciated.
 
The Body is not missing. I am mixing C++ and C#. When I access the body in the C# code I get -
_message = "Cannot deserialize the message passed as an argument. Cannot recognize the serialization format."
Body looks like -
<?xml version="1.0"?><faxModemEvent
66 61 78 44 65 76 69 63 65 faxDevice
3D 22 43 4F 4D 31 30 22 20 ="COM10"
65 76 65 6E 74 49 64 3D 22 eventId="
31 31 22 20 70 61 67 65 4E 11" pageN
75 6D 62 65 72 3D 22 30 22 umber="0"
20 73 75 63 63 65 65 64 65 succeede
64 3D 22 30 22 20 46 61 78 d="0" Fax
43 6F 64 65 3D 22 33 22 20 Code="3"
4C 69 6E 65 43 6F 64 65 3D LineCode=
22 32 35 39 22 3E 20 3C 65 "259"> <e
76 65 6E 74 4D 65 73 73 61 ventMessa
67 65 3E 3C 21 5B 43 44 41 ge><![CDA
54 41 5B 44 69 61 6C 3A 20 TA[Dial:
4E 6F 20 6C 6F 6F 70 20 63 No loop c
75 72 72 65 6E 74 20 64 65 urrent de
74 65 63 74 65 64 2E 5D 5D tected.]]
3E 3C 2F 65 76 65 6E 74 4D ></eventM
65 73 73 61 67 65 3E 3C 2F essage></
66 61 78 4D 6F 64 65 6D 45 faxModemE
76 65 6E 74 3E vent>

C# code -

protected void Page_Load(object sender, System.EventArgs e)
{

SelectedQue = Session[SELECTEDQUE].ToString();
SelectedID = Session[SELECTEDID].ToString();

txtMsgId.Text = SelectedID;

MessageQueue testQ = new MessageQueue(SelectedQue);
testQ.Formatter = new XmlMessageFormatter(new Type[]{typeof(string)});
// testQ.Formatter = new ActiveXMessageFormatter();

testQ.MessageReadPropertyFilter.SetAll();

MessageEnumerator sthEnum = testQ.GetMessageEnumerator();
sthEnum.Reset();
while(sthEnum.MoveNext())
{
if(sthEnum.Current.Id == txtMsgId.Text)
{
Label6.Text = "Message \"" +sthEnum.Current.Label+ "\" Details";
txtMsgPriority.Text = sthEnum.Current.Priority.ToString();
txtMsgSent.Text = sthEnum.Current.SentTime.ToString("G");
try
{
txtMsgBody.Value = sthEnum.Current.Body.ToString();
}
catch (Exception ex)
{

txtMsgBody.Value = " ";
}
break;
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top