|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
JavaComputeNode and Peoplesoft Component Interfaces |
« View previous topic :: View next topic » |
Author |
Message
|
rsandoz |
Posted: Thu Oct 26, 2006 11:49 am Post subject: JavaComputeNode and Peoplesoft Component Interfaces |
|
|
Novice
Joined: 12 Oct 2006 Posts: 17
|
I am trying to send a component interface message to create a row in the URL table in peoplesoft. I can do this fine with ESQL:
Code: |
DECLARE BO_PSHR_URL_TABLE NAMESPACE 'http://www.ibm.com/websphere/crossworlds/2002/BOSchema/BO_PSHR_URL_TABLE';
CREATE COMPUTE MODULE WUTEST_URL_TABLE_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- copy message headers
DECLARE I INTEGER;
DECLARE J INTEGER;
SET I = 1;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
-- set output properties
SET OutputRoot.Properties.MessageSet = 'HLJB6V4002001';
SET OutputRoot.Properties.MessageType = 'BO_PSHR_URL_TABLE';
SET OutputRoot.Properties.MessageDomain = 'MRM';
SET OutputRoot.Properties.MessageFormat = 'CwXML';
SET OutputRoot.MQMD.Format = 'MQHRF2 ';
SET OutputRoot.MQRFH2.(MQRFH2.Field)Format = 'MQSTR ';
-- query and send data
SET OutputRoot.MRM.verb = 'Create';
SET OutputRoot.MRM.BO_PSHR_URL_TABLE:URL_ID = '201';
SET OutputRoot.MRM.BO_PSHR_URL_TABLE:DESCR = 'Test description';
SET OutputRoot.MRM.BO_PSHR_URL_TABLE:URL = 'www.test.com';
RETURN TRUE;
END;
END MODULE;
|
I attempted this with Java, but am having little success
Code: |
import com.ibm.broker.javacompute.MbJavaComputeNode;
import com.ibm.broker.plugin.*;
public class WUTEST_URL_TABLE_JavaCompute extends MbJavaComputeNode {
private void dumpNodes(MbElement node, int level) throws MbException {
while (node!=null) {
char spaces[] = new char[level];
java.util.Arrays.fill(spaces,' ');
System.out.print(new String(spaces) + "<" + node.getName() + ">" + (node.getValue()!=null?node.getValue().toString().trim():""));
if (node.getFirstChild()!=null)
System.out.println("");
dumpNodes(node.getFirstChild(),level + 2);
if (node.getFirstChild()!=null)
System.out.print(new String(spaces));
System.out.println("</" + node.getName() + ">");
node = node.getNextSibling();
};
}
public void evaluate(MbMessageAssembly contact admin) throws MbException {
System.out.println("\n\nStarting");
MbOutputTerminal out = getOutputTerminal("out");
MbMessage inMessage = contact admin.getMessage();
MbMessage outMessage = new MbMessage(inMessage);
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin, outMessage);
try {
MbElement outRoot = outMessage.getRootElement();
outRoot.setNamespace("http://www.ibm.com/websphere/crossworlds/2002/BOSchema/BO_PSHR_URL_TABLE");
System.out.println("\nDUMPING(BEFORE)");
dumpNodes(outRoot,0);
for (MbElement header = outRoot.getFirstChild();header.getNextSibling() != null;header = header.getNextSibling()) {
if (header.getName().equals("Properties")) {
for (MbElement properties = header.getFirstChild();properties.getNextSibling() != null;properties = properties.getNextSibling()){
if (properties.getName().equals("MessageSet"))
properties.setValue("HLJB6V4002001");
if (properties.getName().equals("MessageType")) {
properties.setValue("BO_PSHR_URL_TABLE");
properties.createElementAfter(MbElement.TYPE_NAME,"MessageDomain","MRM");
}
if (properties.getName().equals("MessageFormat"))
properties.setValue("CwXML");
}
}
if (header.getName().equals("MQMD")) {
for (MbElement mqmd = header.getFirstChild();mqmd.getNextSibling() != null;mqmd = mqmd.getNextSibling()){
if (mqmd.getName().equals("Format"))
mqmd.setValue("MQHRF2 ");
}
MbElement mqrfh2 = header.createElementAfter(MbElement.TYPE_NAME,"MQRFH2",null);
mqrfh2.createElementAsFirstChild(MbElement.TYPE_NAME,"(MQRFH2.Field)Format","MQSTR ");
MbElement mrm = header.createElementAfter(MbElement.TYPE_NAME,"MRM",null);
mrm.createElementAsFirstChild(MbElement.TYPE_NAME,"verb","Create");
mrm.createElementAsLastChild(MbElement.TYPE_NAME,"BO_PSHR_URL_TABLE:URL_ID","201");
mrm.createElementAsLastChild(MbElement.TYPE_NAME,"BO_PSHR_URL_TABLE:DESCR","Test description");
mrm.createElementAsLastChild(MbElement.TYPE_NAME,"BO_PSHR_URL_TABLE:URL","www.test.com");
}
}
System.out.println("\nDUMPING(AFTER)");
dumpNodes(outRoot,0);
out.propagate(outAssembly);
} catch (Exception e) {
e.printStackTrace();
} finally {
outMessage.clearMessage();
}
}
}
|
Any suggestions? |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Oct 26, 2006 12:06 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
rsandoz |
Posted: Thu Oct 26, 2006 12:46 pm Post subject: |
|
|
Novice
Joined: 12 Oct 2006 Posts: 17
|
I attempted that as well with no success:
relevant changes:
Code: |
//MbMessage outMessage = new MbMessage(inMessage);
MbMessage outMessage = new MbMessage();
...
copyMessageHeaders(inMessage, outMessage);
...
public void copyMessageHeaders(MbMessage inMessage, MbMessage outMessage)
...
|
and the whole code:
Code: |
import com.ibm.broker.javacompute.MbJavaComputeNode;
import com.ibm.broker.plugin.*;
public class WUTEST_URL_TABLE_JavaCompute extends MbJavaComputeNode {
private void dumpNodes(MbElement node, int level) throws MbException {
while (node!=null) {
char spaces[] = new char[level];
java.util.Arrays.fill(spaces,' ');
System.out.print(new String(spaces) + "<" + node.getName() + ">" + (node.getValue()!=null?node.getValue().toString().trim():""));
if (node.getFirstChild()!=null)
System.out.println("");
dumpNodes(node.getFirstChild(),level + 2);
if (node.getFirstChild()!=null)
System.out.print(new String(spaces));
System.out.println("</" + node.getName() + ">");
node = node.getNextSibling();
};
}
public void evaluate(MbMessageAssembly contact admin) throws MbException {
System.out.println("\n\nStarting");
MbOutputTerminal out = getOutputTerminal("out");
MbMessage inMessage = contact admin.getMessage();
//MbMessage outMessage = new MbMessage(inMessage);
MbMessage outMessage = new MbMessage();
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin, outMessage);
try {
System.out.println("\nDUMPING(IN)");
dumpNodes(inMessage.getRootElement(),0);
copyMessageHeaders(inMessage, outMessage);
MbElement outRoot = outMessage.getRootElement();
outRoot.setNamespace("http://www.ibm.com/websphere/crossworlds/2002/BOSchema/BO_PSHR_URL_TABLE");
System.out.println("\nDUMPING(BEFORE)");
dumpNodes(outRoot,0);
for (MbElement header = outRoot.getFirstChild();header.getNextSibling() != null;header = header.getNextSibling()) {
if (header.getName().equals("Properties")) {
for (MbElement properties = header.getFirstChild();properties.getNextSibling() != null;properties = properties.getNextSibling()){
if (properties.getName().equals("MessageSet"))
properties.setValue("HLJB6V4002001");
if (properties.getName().equals("MessageType")) {
properties.setValue("BO_PSHR_URL_TABLE");
properties.createElementAfter(MbElement.TYPE_NAME,"MessageDomain","MRM");
}
if (properties.getName().equals("MessageFormat"))
properties.setValue("CwXML");
}
}
if (header.getName().equals("MQMD")) {
for (MbElement mqmd = header.getFirstChild();mqmd.getNextSibling() != null;mqmd = mqmd.getNextSibling()){
if (mqmd.getName().equals("Format"))
mqmd.setValue("MQHRF2 ");
}
MbElement mqrfh2 = header.createElementAfter(MbElement.TYPE_NAME,"MQRFH2",null);
mqrfh2.createElementAsFirstChild(MbElement.TYPE_NAME,"(MQRFH2.Field)Format","MQSTR ");
MbElement mrm = header.createElementAfter(MbElement.TYPE_NAME,"MRM",null);
mrm.createElementAsFirstChild(MbElement.TYPE_NAME,"verb","Create");
mrm.createElementAsLastChild(MbElement.TYPE_NAME,"BO_PSHR_URL_TABLE:URL_ID","201");
mrm.createElementAsLastChild(MbElement.TYPE_NAME,"BO_PSHR_URL_TABLE:DESCR","Test description");
mrm.createElementAsLastChild(MbElement.TYPE_NAME,"BO_PSHR_URL_TABLE:URL","www.test.com");
}
}
System.out.println("\nDUMPING(AFTER)");
dumpNodes(outRoot,0);
out.propagate(outAssembly);
} catch (Exception e) {
e.printStackTrace();
} finally {
outMessage.clearMessage();
}
}
public void copyMessageHeaders(MbMessage inMessage, MbMessage outMessage) throws MbException {
MbElement outRoot = outMessage.getRootElement();
MbElement header = inMessage.getRootElement().getFirstChild();
while (header != null && header.getNextSibling() != null) {
outRoot.addAsLastChild(header.copy());
header = header.getNextSibling();
}
}
}
|
|
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Oct 26, 2006 1:08 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
So what's actually wrong with the message that gets generated? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
rsandoz |
Posted: Fri Oct 27, 2006 3:46 am Post subject: |
|
|
Novice
Joined: 12 Oct 2006 Posts: 17
|
It does not process the component interface. When using RfhUtil, the message generated by ESQL looks like:
Code: |
06.39.14 Msg read from PEOPLESOFT.REQUESTQ length=626 (data 490 dlq 0 rfh 136 cics 0 ims 0)
00000000h: 4D 44 20 20 01 00 00 00 00 00 00 00 08 00 00 00 ; MD ............
00000010h: FF FF FF FF 00 00 00 00 11 01 00 00 33 03 00 00 ; ÿÿÿÿ........3...
00000020h: 4D 51 48 52 46 32 20 20 00 00 00 00 00 00 00 00 ; MQHRF2 ........
00000030h: 41 4D 51 20 4D 42 4C 4F 43 41 4C 20 20 20 20 20 ; AMQ MBLOCAL
00000040h: 63 AD 40 45 20 00 30 02 00 00 00 00 00 00 00 00 ; cÂ@E .0.........
00000050h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
00000060h: 00 00 00 00 20 20 20 20 20 20 20 20 20 20 20 20 ; ....
00000070h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
00000080h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
00000090h: 20 20 20 20 4D 42 4C 4F 43 41 4C 20 20 20 20 20 ; MBLOCAL
000000a0h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
000000b0h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
000000c0h: 20 20 20 20 64 62 32 61 64 6D 69 6E 20 20 20 20 ; db2admin
000000d0h: 16 01 05 15 00 00 00 0E 5D 50 1B 75 65 33 4D DE ; ........]P.ue3MÞ
000000e0h: 6F 59 52 E9 03 00 00 00 00 00 00 00 00 00 00 0B ; oYRé............
000000f0h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
00000100h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
00000110h: 1C 00 00 00 20 20 20 20 20 20 20 20 20 20 20 20 ; ....
00000120h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
00000130h: 32 30 30 36 31 30 32 37 31 31 33 39 31 31 39 39 ; 2006102711391199
00000140h: 20 20 20 20 00 00 00 00 00 00 00 00 00 00 00 00 ; ............
00000150h: 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 ; ................
00000160h: 00 00 00 00 00 00 00 00 FF FF FF FF 52 46 48 20 ; ........ÿÿÿÿRFH
00000170h: 00 00 00 02 00 00 00 88 00 00 02 22 00 00 01 B5 ; .......ˆ..."...µ
00000180h: 4D 51 53 54 52 20 20 20 00 00 00 00 00 00 04 B8 ; MQSTR .......¸
00000190h: 00 00 00 60 3C 6D 63 64 3E 3C 4D 73 64 3E 6D 72 ; ...`<mcd><Msd>mr
000001a0h: 6D 3C 2F 4D 73 64 3E 3C 53 65 74 3E 48 4C 4A 42 ; m</Msd><Set>HLJB
000001b0h: 36 56 34 30 30 32 30 30 31 3C 2F 53 65 74 3E 3C ; 6V4002001</Set><
000001c0h: 54 79 70 65 3E 42 4F 5F 50 53 48 52 5F 55 52 4C ; Type>BO_PSHR_URL
000001d0h: 5F 54 41 42 4C 45 3C 2F 54 79 70 65 3E 3C 46 6D ; _TABLE</Type><Fm
000001e0h: 74 3E 43 77 58 4D 4C 3C 2F 46 6D 74 3E 3C 2F 6D ; t>CwXML</Fmt></m
000001f0h: 63 64 3E 20 3C 3F 78 6D 6C 20 76 65 72 73 69 6F ; cd> <?xml versio
00000200h: 6E 3D 22 31 2E 30 22 3F 3E 3C 42 4F 5F 50 53 48 ; n="1.0"?><BO_PSH
00000210h: 52 5F 55 52 4C 5F 54 41 42 4C 45 3A 42 4F 5F 50 ; R_URL_TABLE:BO_P
00000220h: 53 48 52 5F 55 52 4C 5F 54 41 42 4C 45 20 78 6D ; SHR_URL_TABLE xm
00000230h: 6C 6E 73 3A 42 4F 5F 50 53 48 52 5F 55 52 4C 5F ; lns:BO_PSHR_URL_
00000240h: 54 41 42 4C 45 3D 22 68 74 74 70 3A 2F 2F 77 77 ; TABLE="http://ww
00000250h: 77 2E 69 62 6D 2E 63 6F 6D 2F 77 65 62 73 70 68 ; w.ibm.com/websph
00000260h: 65 72 65 2F 63 72 6F 73 73 77 6F 72 6C 64 73 2F ; ere/crossworlds/
00000270h: 32 30 30 32 2F 42 4F 53 63 68 65 6D 61 2F 42 4F ; 2002/BOSchema/BO
00000280h: 5F 50 53 48 52 5F 55 52 4C 5F 54 41 42 4C 45 22 ; _PSHR_URL_TABLE"
00000290h: 20 78 6D 6C 6E 73 3A 78 73 64 3D 22 68 74 74 70 ; xmlns:xsd="http
000002a0h: 3A 2F 2F 77 77 77 2E 77 33 2E 6F 72 67 2F 32 30 ; ://www.w3.org/20
000002b0h: 30 31 2F 58 4D 4C 53 63 68 65 6D 61 22 20 78 6D ; 01/XMLSchema" xm
000002c0h: 6C 6E 73 3A 78 73 69 3D 22 68 74 74 70 3A 2F 2F ; lns:xsi="http://
000002d0h: 77 77 77 2E 77 33 2E 6F 72 67 2F 32 30 30 31 2F ; www.w3.org/2001/
000002e0h: 58 4D 4C 53 63 68 65 6D 61 2D 69 6E 73 74 61 6E ; XMLSchema-instan
000002f0h: 63 65 22 20 76 65 72 62 3D 22 43 72 65 61 74 65 ; ce" verb="Create
00000300h: 22 3E 3C 42 4F 5F 50 53 48 52 5F 55 52 4C 5F 54 ; "><BO_PSHR_URL_T
00000310h: 41 42 4C 45 3A 55 52 4C 5F 49 44 3E 32 30 31 3C ; ABLE:URL_ID>201<
00000320h: 2F 42 4F 5F 50 53 48 52 5F 55 52 4C 5F 54 41 42 ; /BO_PSHR_URL_TAB
00000330h: 4C 45 3A 55 52 4C 5F 49 44 3E 3C 42 4F 5F 50 53 ; LE:URL_ID><BO_PS
00000340h: 48 52 5F 55 52 4C 5F 54 41 42 4C 45 3A 44 45 53 ; HR_URL_TABLE:DES
00000350h: 43 52 3E 54 65 73 74 20 64 65 73 63 72 69 70 74 ; CR>Test descript
00000360h: 69 6F 6E 3C 2F 42 4F 5F 50 53 48 52 5F 55 52 4C ; ion</BO_PSHR_URL
00000370h: 5F 54 41 42 4C 45 3A 44 45 53 43 52 3E 3C 42 4F ; _TABLE:DESCR><BO
00000380h: 5F 50 53 48 52 5F 55 52 4C 5F 54 41 42 4C 45 3A ; _PSHR_URL_TABLE:
00000390h: 55 52 4C 3E 77 77 77 2E 74 65 73 74 2E 63 6F 6D ; URL>www.test.com
000003a0h: 3C 2F 42 4F 5F 50 53 48 52 5F 55 52 4C 5F 54 41 ; </BO_PSHR_URL_TA
000003b0h: 42 4C 45 3A 55 52 4C 3E 3C 2F 42 4F 5F 50 53 48 ; BLE:URL></BO_PSH
000003c0h: 52 5F 55 52 4C 5F 54 41 42 4C 45 3A 42 4F 5F 50 ; R_URL_TABLE:BO_P
000003d0h: 53 48 52 5F 55 52 4C 5F 54 41 42 4C 45 3E ; SHR_URL_TABLE>
|
Java produces:
Code: |
06.42.20 Msg read from PEOPLESOFT.REQUESTQ length=0
00000000h: 4D 44 20 20 01 00 00 00 00 00 00 00 08 00 00 00 ; MD ............
00000010h: FF FF FF FF 00 00 00 00 11 01 00 00 33 03 00 00 ; ÿÿÿÿ........3...
00000020h: 20 20 20 20 20 20 20 20 00 00 00 00 00 00 00 00 ; ........
00000030h: 41 4D 51 20 4D 42 4C 4F 43 41 4C 20 20 20 20 20 ; AMQ MBLOCAL
00000040h: 63 AD 40 45 20 00 24 02 00 00 00 00 00 00 00 00 ; cÂ@E .$.........
00000050h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
00000060h: 00 00 00 00 20 20 20 20 20 20 20 20 20 20 20 20 ; ....
00000070h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
00000080h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
00000090h: 20 20 20 20 4D 42 4C 4F 43 41 4C 20 20 20 20 20 ; MBLOCAL
000000a0h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
000000b0h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
000000c0h: 20 20 20 20 64 62 32 61 64 6D 69 6E 20 20 20 20 ; db2admin
000000d0h: 16 01 05 15 00 00 00 0E 5D 50 1B 75 65 33 4D DE ; ........]P.ue3MÞ
000000e0h: 6F 59 52 E9 03 00 00 00 00 00 00 00 00 00 00 0B ; oYRé............
000000f0h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
00000100h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
00000110h: 1C 00 00 00 20 20 20 20 20 20 20 20 20 20 20 20 ; ....
00000120h: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
00000130h: 32 30 30 36 31 30 32 37 31 31 34 31 34 39 33 35 ; 2006102711414935
00000140h: 20 20 20 20 00 00 00 00 00 00 00 00 00 00 00 00 ; ............
00000150h: 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 ; ................
00000160h: 00 00 00 00 00 00 00 00 FF FF FF FF ; ........ÿÿÿÿ
|
|
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 27, 2006 3:59 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
rsandoz |
Posted: Fri Oct 27, 2006 11:10 am Post subject: |
|
|
Novice
Joined: 12 Oct 2006 Posts: 17
|
Thanks, I tried that and got closer. Much appreciated. I am not quite there yet.
(A) My guess is that I need to do something similar for MQRFH2, since there was an MQRFH2 parser in the link you sent me. That being said, I replaced:
Code: |
MbElement mqrfh2 = header.createElementAfter(MbElement.TYPE_NAME,"MQRFH2",null);
|
with:
Code: |
MbElement mqrfh2 = header.createElementAfter("MQRFH2");
|
which did not work, in fact, my java exits without so much as showing a stack trace and my message goes straight to DLQ
(B) I also tried another experiement. I took the esql compute node and put it in series with the java compute node. ie the message got to esql then to java then to out. As I tested, I commented out an esql line and place in a java line to reproduce the same functionality. I seem to not be able to reproduce what this line does:
Code: |
SET OutputRoot.MQRFH2.(MQRFH2.Field)Format = 'MQSTR ';
|
I included the complete code for the above (A) and (B) in the following:
(A) Complete code
Code: |
outRoot.setNamespace("http://www.ibm.com/websphere/crossworlds/2002/BOSchema/BO_PSHR_URL_TABLE");
for (MbElement header = outRoot.getFirstChild();header!=null;header = header.getNextSibling()) {
if (header.getName().equals("Properties")) {
for (MbElement properties = header.getFirstChild();properties != null;properties = properties.getNextSibling()){
if (properties.getName().equals("MessageSet"))
properties.setValue("HLJB6V4002001");
if (properties.getName().equals("MessageType"))
properties.setValue("BO_PSHR_URL_TABLE");
if (properties.getName().equals("MessageFormat"))
properties.setValue("CwXML");
}
}
if (header.getName().equals("MQMD")) {
for (MbElement mqmd = header.getFirstChild();mqmd != null;mqmd = mqmd.getNextSibling()){
if (mqmd.getName().equals("Format"))
mqmd.setValue("MQHRF2 ");
}
System.out.println("Adding MQRFH2");
// This is probably wrong as there is a parser in that link you sent me called MQRFH2
MbElement mqrfh2 = header.createElementAfter(MbElement.TYPE_NAME,"MQRFH2",null);
// When I do this, my java exits without so much as showing a stack trace and my message goes straight to DLQ
//MbElement mqrfh2 = header.createElementAfter("MQRFH2");
System.out.println("Done Adding MQRFH2");
mqrfh2.createElementAsFirstChild(MbElement.TYPE_NAME,"Format","MQSTR ");
MbElement mcd = mqrfh2.createElementAsLastChild(MbElement.TYPE_NAME,"mcd",null);
MbElement msd = mcd.createElementAsFirstChild(MbElement.TYPE_NAME,"Msd","mrm");
msd.createElementAsFirstChild(MbElement.TYPE_NAME,"","mrm");
MbElement set = mcd.createElementAsLastChild(MbElement.TYPE_NAME,"Set","HLJB6V4002001");
set.createElementAsFirstChild(MbElement.TYPE_NAME,"","HLJB6V4002001");
MbElement type = mcd.createElementAsLastChild(MbElement.TYPE_NAME,"Type","BO_PSHR_URL_TABLE");
type.createElementAsFirstChild(MbElement.TYPE_NAME,"","BO_PSHR_URL_TABLE");
MbElement fmt = mcd.createElementAsLastChild(MbElement.TYPE_NAME,"Fmt","CwXML");
fmt.createElementAsFirstChild(MbElement.TYPE_NAME,"","CwXML");
MbElement mrm = mqrfh2.createElementAfter("MRM");
mrm.createElementAsFirstChild(MbElement.TYPE_NAME,"verb","Create");
mrm.createElementAsLastChild(MbElement.TYPE_NAME,"URL_ID","201");
mrm.createElementAsLastChild(MbElement.TYPE_NAME,"DESCR","Test description");
mrm.createElementAsLastChild(MbElement.TYPE_NAME,"URL","www.test.com");
}
}
|
(B) Complete code
Code: |
ESQL:
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- copy message headers
DECLARE I INTEGER;
DECLARE J INTEGER;
SET I = 1;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
-- set output properties
--SET OutputRoot.Properties.MessageSet = 'HLJB6V4002001';
--SET OutputRoot.Properties.MessageType = 'BO_PSHR_URL_TABLE';
--SET OutputRoot.Properties.MessageFormat = 'CwXML';
--SET OutputRoot.Properties.MessageDomain = 'MRM';
--SET OutputRoot.MQMD.Format = 'MQHRF2 ';
-- this does something hidden (I want Java to do this)
SET OutputRoot.MQRFH2.(MQRFH2.Field)Format = 'MQSTR ';
-- query and send data
--SET OutputRoot.MRM.verb = 'Create';
--SET OutputRoot.MRM.BO_PSHR_URL_TABLE:URL_ID = '201';
--SET OutputRoot.MRM.BO_PSHR_URL_TABLE:DESCR = 'Test description';
--SET OutputRoot.MRM.BO_PSHR_URL_TABLE:URL = 'www.test.com';
RETURN TRUE;
END;
JAVA:
import com.ibm.broker.javacompute.MbJavaComputeNode;
import com.ibm.broker.plugin.*;
public class WUTEST_URL_TABLE_JavaCompute2 extends MbJavaComputeNode {
public void evaluate(MbMessageAssembly contact admin) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
MbMessage inMessage = contact admin.getMessage();
MbMessage outMessage = new MbMessage(inMessage);
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin,outMessage);
MbElement outRoot = outMessage.getRootElement();
//outRoot.setNamespace("http://www.ibm.com/websphere/crossworlds/2002/BOSchema/BO_PSHR_URL_TABLE");
for (MbElement header = outRoot.getFirstChild();header!=null;header = header.getNextSibling()) {
if (header.getName().equals("Properties")) {
for (MbElement properties = header.getFirstChild();properties != null;properties = properties.getNextSibling()){
if (properties.getName().equals("MessageSet"))
properties.setValue("HLJB6V4002001");
if (properties.getName().equals("MessageType"))
properties.setValue("BO_PSHR_URL_TABLE");
if (properties.getName().equals("MessageFormat"))
properties.setValue("CwXML");
}
}
/* try to create MQHRF2 in Java
if (header.getName().equals("MQMD")) {
for (MbElement mqmd = header.getFirstChild();mqmd != null;mqmd = mqmd.getNextSibling()){
if (mqmd.getName().equals("Format"))
mqmd.setValue("MQHRF2 ");
}
MbElement mqrfh2 = header.createElementAfter(MbElement.TYPE_NAME, "MQRFH2", null);
mqrfh2.createElementAsFirstChild(MbElement.TYPE_NAME,"Format","MQSTR ");
MbElement mcd = mqrfh2.createElementAsLastChild(MbElement.TYPE_NAME,"mcd",null);
MbElement msd = mcd.createElementAsFirstChild(MbElement.TYPE_NAME,"Msd","mrm");
msd.createElementAsFirstChild(MbElement.TYPE_NAME,"","mrm");
MbElement set = mcd.createElementAsLastChild(MbElement.TYPE_NAME,"Set","HLJB6V4002001");
set.createElementAsFirstChild(MbElement.TYPE_NAME,"","HLJB6V4002001");
MbElement type = mcd.createElementAsLastChild(MbElement.TYPE_NAME,"Type","BO_PSHR_URL_TABLE");
type.createElementAsFirstChild(MbElement.TYPE_NAME,"","BO_PSHR_URL_TABLE");
MbElement fmt = mcd.createElementAsLastChild(MbElement.TYPE_NAME,"Fmt","CwXML");
fmt.createElementAsFirstChild(MbElement.TYPE_NAME,"","CwXML");
MbElement mrm = mqrfh2.createElementAfter("MRM");
MbElement verb = mrm.createElementAsFirstChild(MbElement.TYPE_NAME,"verb","Create");
MbElement urlid = verb.createElementAfter(MbElement.TYPE_NAME,"URL_ID","201");
MbElement descr = urlid.createElementAfter(MbElement.TYPE_NAME,"DESCR","Test description");
descr.createElementAfter(MbElement.TYPE_NAME,"URL","www.test.com");
}*/
/* I let esql create the MQHRF2 node and I just added the children */
if (header.getName().equals("MQRFH2")) {
for (MbElement mqrfh2 = header.getFirstChild();mqrfh2 != null;mqrfh2 = mqrfh2.getNextSibling()){
if (mqrfh2.getName().equals("Format")) {
mqrfh2.setValue("MQSTR ");
MbElement mcd = mqrfh2.createElementAfter(MbElement.TYPE_NAME,"mcd",null);
MbElement msd = mcd.createElementAsFirstChild(MbElement.TYPE_NAME,"Msd","mrm");
MbElement set = msd.createElementAfter(MbElement.TYPE_NAME,"Set","HLJB6V4002001");
MbElement type = set.createElementAfter(MbElement.TYPE_NAME,"Type","BO_PSHR_URL_TABLE");
MbElement fmt = type.createElementAfter(MbElement.TYPE_NAME,"Fmt","CwXML");
}
}
MbElement mrm = header.createElementAfter("MRM");
MbElement verb = mrm.createElementAsFirstChild(MbElement.TYPE_NAME,"verb","Create");
MbElement urlid = verb.createElementAfter(MbElement.TYPE_NAME,"BO_PSHR_URL_TABLE:URL_ID","201");
MbElement descr = urlid.createElementAfter(MbElement.TYPE_NAME,"BO_PSHR_URL_TABLE:DESCR","Test description");
descr.createElementAfter(MbElement.TYPE_NAME,"BO_PSHR_URL_TABLE:URL","www.test.com");
}
}
try {
System.out.println("\nDUMPING(outRoot)");
dumpNodes(outRoot,0);
out.propagate(outAssembly);
} catch (Exception e) {
e.printStackTrace();
} finally {
outMessage.clearMessage();
}
}
private void dumpNodes(MbElement node, int level) throws MbException {
while (node!=null) {
char spaces[] = new char[level];
java.util.Arrays.fill(spaces,' ');
System.out.print(new String(spaces) + "<" + node.getName() + ">" + (node.getValue()!=null?node.getValue().toString().trim():""));
if (node.getFirstChild()!=null)
System.out.println("");
dumpNodes(node.getFirstChild(),level + 2);
if (node.getFirstChild()!=null)
System.out.print(new String(spaces));
System.out.println("</" + node.getName() + ">");
node = node.getNextSibling();
};
}
}
|
|
|
Back to top |
|
 |
rsandoz |
Posted: Fri Oct 27, 2006 11:35 am Post subject: |
|
|
Novice
Joined: 12 Oct 2006 Posts: 17
|
I think I might have fixed my own problem. I think this parser has letters swapped around.
MQRFH2 => MQHRF2
not a perfect match. The java version has and extra V2 folder checked (other) where my esql does not. Plus I dont see the Data Format field filled out on the Java side. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 27, 2006 6:09 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
The MQ Rules and Formatting Header version 2 is identfied by the MQ Format constant of "MQHRF2 ".
And if you look at the "Class Name" column of the table in the link I posted, you'll see that the Class Name of the MQRFH2 parser is "MQHRF2".
rsandoz wrote: |
I think I might have fixed my own problem. |
Then you win! Congratulations!  _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|