我们使用Java (Java )应用程序,并生成XML文件,以便将它们发送到远程.NET应用程序,而MSMQ读取在它们的一端。XML文件是由JDom生成的,如下所示:
// add elements...
Document doc = new Document(root);
String XmlData = new XMLOutputter(Format.getPrettyFormat().setOmitEncoding(true)).outputString(doc);
try {
SendFile( XmlData, "title" , "path");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (MessageQueueException e) {
e.printStackTrace();
}然后我们使用这个函数,使用MsmqJava library发送文件:
private void SendFile(String data, String title, String outputPath) throws UnsupportedEncodingException, MessageQueueException{
String qname="name_of_the_queue";
String fullname= "server_path" + qname;
String body = data;
String label = title;
String correlationId= "L:none";
try {
Queue queue= new Queue(fullname);
Message msg= new Message(body, label, correlationId);
queue.send(msg);
} catch (MessageQueueException ex1) {
System.out.println("Put failure: " + ex1.toString());
}
}他们正确地收到了文件,但是他们告诉我们bodyType被设置为"VT_EMPTY“,而他们想要的是"VT_BSTR",而我们还没有找到关于如何修复这个问题的线索。如果你知道另一个库来做这项工作,或者这个库的变通方法,我们可以毫不费力地进行更改。
谢谢!
发布于 2012-07-27 17:32:44
查看您使用的库的文档,您无法使用该库。
Jmsmqqueue也没有提供您需要的功能。
sun似乎也有一个适配器:https://wikis.oracle.com/display/JavaCAPS/Sun+Adapter+for+MSMQ
https://stackoverflow.com/questions/11684910
复制相似问题