我们在Java(Java EE)应用程序上工作,并且我们生成XML文件以便将它们发送到MSMQ读取的远程.NET应用程序。
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”,我们还没有找到解决这个问题的线索。如果你知道另一个做这项工作的lib,或者解决这个问题的方法,我们可以改变,没有问题。
谢谢 !