Author |
Message
|
boristep |
Posted: Thu Apr 03, 2014 9:34 am Post subject: start file transfer by putting message in the command queue |
|
|
Novice
Joined: 02 Jan 2013 Posts: 11
|
According to InfoCenter it's possible start a file transfer by putting a file transfer message on the command queue of the source agent. For example SYSTEM.FTE.COMMAND.AGENT01
There is a sample program:
public class MQSample {
// code identifier
static final String sccsid = "@(#) samples/wmqjava/MQSample.java, jmscc.samples, k701, k701-110-130204 1.8.1.1 09/08/17 07:42:55";
// define the name of the QueueManager
private static final String qManager = "QMA";
// and define the name of the Queue
private static final String qName = "SYSTEM.FTE.COMMAND.AGENTA";
public static void main(String args[]) {
try {
// Create a connection to the QueueManager
System.out.println("Connecting to queue manager: " + qManager);
MQQueueManager qMgr = new MQQueueManager(qManager);
// Set up the options on the queue we wish to open
int openOptions = MQConstants.MQOO_OUTPUT;
// Now specify the queue that we wish to open and the open options
System.out.println("Accessing queue: " + qName);
MQQueue queue = qMgr.accessQueue(qName, openOptions);
// Define a simple WebSphere MQ Message ...
MQMessage msg = new MQMessage();
// ... and write some text in UTF8 format
String s = new String(" <?xml version=\"1.0\" encoding=\"UTF-8\"?><request version=\"4.00\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"FileTransfer.xsd\">\n"+
"<managedTransfer>\n"+
"<originator>\n"+
"<hostName>10.0.0.6</hostName>\n"+
"<userID>BorisT</userID>\n"+
"</originator>\n"+
"<sourceAgent QMgr=\"QMA\" agent=\"AGENTA\"/>\n"+
"<destinationAgent QMgr=\"QMB\" agent=\"AGENTB\"/>\n"+
"<transferSet>\n"+
"<item checksumMethod=\"MD5\" mode=\"binary\">\n"+
"<source disposition=\"leave\" recursive=\"false\">\n"+
"<file>c:\\tmp\\icon.gif</file>\n"+
"</source>\n"+
"<destination exist=\"overwrite\" type=\"directory\">\n"+
"<file>C:\\TEST</file>\n"+
"</destination>\n"+
"</item>\n"+
"</transferSet>\n"+
"</managedTransfer>\n"+
"</request>");
System.out.println("The message is: " + s);
msg.writeUTF(s);
// Specify the default put message options
MQPutMessageOptions pmo = new MQPutMessageOptions();
// Put the message to the queue
System.out.println("Sending a message...");
queue.put(msg, pmo);
The file transfer fails because malformed XML, I suppose that is 2 byte of the message length at the beginning of the message.
What is a solution? |
|
Back to top |
|
 |
tomleend |
Posted: Sat Apr 05, 2014 1:27 am Post subject: |
|
|
Acolyte
Joined: 24 Jan 2014 Posts: 51
|
Hi boristep,
I haven't tried compiling or running or code snippet but the first thing I'd suggest is removing the new line characters you have included in your XML string and see if that helps. |
|
Back to top |
|
 |
boristep |
Posted: Sat Apr 05, 2014 9:09 pm Post subject: |
|
|
Novice
Joined: 02 Jan 2013 Posts: 11
|
It does not help
The message is: Content is not allowed in prolog
My understanding it says that something wrong in the beginning of the message |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Apr 06, 2014 11:12 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Did you set the MQMD Format and CCSID fields to the right values before putting the message?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
RogerLacroix |
Posted: Tue Apr 08, 2014 11:51 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
boristep wrote: |
The message is: Content is not allowed in prolog |
XML Prolog is optional and appears before the root element.
Code: |
String s = new String(" <?xml version=\"1.0\" encoding=\"UTF-8\"?><request version=\"4.00\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"FileTransfer.xsd\">\n"+ |
You have a space before <?xml, so change it to:
Code: |
String s = new String("<?xml version=\"1.0\" encoding=\"UTF-8\"?><request version=\"4.00\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"FileTransfer.xsd\">\n"+ |
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
boristep |
Posted: Tue Apr 08, 2014 9:55 pm Post subject: |
|
|
Novice
Joined: 02 Jan 2013 Posts: 11
|
thanks a lot RogerLacroix
this was the problem
 |
|
Back to top |
|
 |
|