我正在尝试使用独立的JMS应用程序与TextMessage(使用Siebel消息在XML格式)运行测试应用程序。我们使用特定于IBM WebSphere MQ。
我得到了QueueConnection, QueueSession和QueueSender对象。
我在下面附上了示例代码。运行时,replymessage为空,我得到异常"致命错误:'com.ibm.xtq.commons.utils.wrappedruntimeexception:根元素需要在格式良好的文档'"。
"TextMessage replyMessage = (TextMessage)msg"行出现异常为什么我得到这个异常,帮助我解决这个问题。
public static void main(String args[]){
MQQueueConnectionFactory factory = new MQQueueConnectionFactory();
factory.setQueueManager(queueManagerName);
factory.setHostName("hostName");
factory.setTransportType(1);
factory.setPort(1111);
factory.setChannel("channel");
connection = factory.createQueueConnection();
connection.start();
boolean transacted = false;
QueueSession session = connection.createQueueSession(transacted, 1);
MQQueue requestQueue = new MQQueue();
requestQueue.setBaseQueueManagerName(queueManagerName);
requestQueue.setBaseQueueName(requestQueueName);
requestQueue.setTargetClient(1);
Queue replyQueue = session.createQueue(replyQueueName);
QueueSender queueSender = session.createSender(requestQueue);
TextMessage requestMessage = session.createTextMessage();
requestMessage.setText(message);
requestMessage.setJMSReplyTo(replyQueue);
queueSender.send(requestMessage);
String selector = "JMSCorrelationID = '" + id + "'";
javax.jms.QueueReceiver queueReceiver = session.createReceiver(replyQueue, selector);
Message msg = queueReceiver.receive(timeout);
TextMessage replyMessage = (TextMessage)msg;
replyMessage.getText();
}
XML内容下面是siebel XML请求(此数据通过JMS发送消息)
<?xml version='1.0' encoding='UTF-8' ?>
<?Siebel-Property-Set EscapeNames='false'?>
<SiebelMessage MessageId='1-1GGX' MessageType='Integration Object' IntObjectName='GL IVR Request' IntObjectFormat='Siebel Hierarchical'>
<GLIVRRequest>
<TransactionName>Policy</TransactionName>
<PolicyNumber>XYZ123</PolicyNumber>
<AgentCode></AgentCode>
<PostalCode></PostalCode>
<WithdrawalAmount></WithdrawalAmount>
<LoanAmount></LoanAmount>
<ApplyToPremium></ApplyToPremium>
<ApplyToPremiumAmount></ApplyToPremiumAmount>
<RequestType></RequestType>
<RequestItemID></RequestItemID>
<SendMethod></SendMethod>
<GLIMCallerFaxNumber></GLIMCallerFaxNumber>
</GLIVRRequest>
</SiebelMessage>
当xml文件为空或null时,会发生这种异常。请检查xml文件对象。这不是siebel格式xml的问题。
但是,如果您收到的响应为"null",请检查接收方部分。