|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Java Plug-in Node Problem |
« View previous topic :: View next topic » |
Author |
Message
|
jax |
Posted: Mon Oct 27, 2003 12:23 am Post subject: Java Plug-in Node Problem |
|
|
 Novice
Joined: 10 Jul 2003 Posts: 12 Location: South Africa
|
Guys,
I have the following Java code to get some data from an HTTP call.
The problem is that I, from the Input Node, get an HTTP string, pass it to a method and then returns a string from the HTTP call.
When I compile the java code, I get the following error:
Quote: |
C:\Java\Apps\MedwareWebInterface.java:43: cannot resolve symbol
symbol : constructor MbMessage (java.lang.String)
location: class com.ibm.broker.plugin.MbMessage
MbMessage outMsg = new MbMessage(msgOut);
^
1 error |
...and this is the Java code:
Code: |
import com.ibm.broker.plugin.*;
public class MedwareWebInterface extends MbNode implements MbNodeInterface
{
String _nodeTraceSetting;
public MedwareWebInterface() throws MbException
{
createInputTerminal("in");
createOutputTerminal("out");
createOutputTerminal("failure");
}
public static String getNodeName()
{
return "MedwareInterface";
}
public void evaluate(MbMessageAssembly assembly, MbInputTerminal in)
throws MbException
{
MbMessage newMsg = new MbMessage(assembly.getMessage());
MbMessageAssembly newAssembly = new MbMessageAssembly(assembly, newMsg);
String msgString = new MbMessage(newAssembly.getMessage()).toString();
String msgOut ="";
try
{
msgOut = new MedwareHttpCall().sendRequest(msgString);
}
catch (Exception e)
{
msgOut = e.getMessage();
}
if(_nodeTraceSetting.equals("debug"))
{
System.out.println("RETURN : "+msgOut );
}
MbMessage outMsg = new MbMessage(msgOut);
MbOutputTerminal out = getOutputTerminal("out");
out.propagate(newAssembly);
}
public String toString()
{
return getName();
}
public String getNodeTraceSetting()
{
return _nodeTraceSetting;
}
public void setNodeTraceSetting(String nodeTraceSetting)
{
_nodeTraceSetting = nodeTraceSetting;
}
} |
[/code]
It seems like I cannot instantiate a new MbMessage witha string variable.
My Java knowledge is very limited, so I cannot think of too many alternatives, please help...
Jax |
|
Back to top |
|
 |
lillo |
Posted: Mon Oct 27, 2003 3:26 am Post subject: |
|
|
Master
Joined: 11 Sep 2001 Posts: 224
|
Hi,
The problem is MbMessage does not accept a string as a parameter to instanciate a new element. MbMessage only accepts another MbMessage to instanciate a new object.
I guess this is the first time you develop a wmqi plugin node. So, take a look to a redbook to see how create new plugins. I would recomend you "Devoloping solutions with WebSphere MQ Integrator".
Cheers, _________________ Lillo
IBM Certified Specialist - WebSphere MQ |
|
Back to top |
|
 |
jax |
Posted: Mon Oct 27, 2003 9:26 pm Post subject: |
|
|
 Novice
Joined: 10 Jul 2003 Posts: 12 Location: South Africa
|
You're quite right, it is the first time I want to develop a WMQI plug-in.
In simple terms, I want to get a string from the Input terminal, do someting with the string, and then get the returned data back into an 'MbMessage' / 'MbMessageAssembly' format so that I can push it through the output terminal.
Do you possibly have a simple example of something like that, anyone?
Thanks in Advance
Jax |
|
Back to top |
|
 |
rwa |
Posted: Tue Oct 28, 2003 1:58 am Post subject: |
|
|
Voyager
Joined: 22 Jan 2002 Posts: 76 Location: Duesseldorf/Germany
|
Hi Jax,
as already said, a new message has to be constructed from an existing message. This is already done with newMsg.
So replace the line "MbMessage outMsg = new MbMessage(msgOut);" with (asuming Message Domain is XML):
// The message body is the last child of the message
MbElement root = newMsg.getRootElement();
MbElement xmlElem = root.getLastChild();
// delete the message body in this message copy
MbElement elems[] = xmlElem.getAllElementsbyPath("/");
For (int i; i < elems.length; i++) {
elems[i].detach();
}
// Now fill the message
xmlElem.createElementAsFirstChild(MbElement.TYPE_NAME,
"Return", (Object) msgOut);
This message has to be released after the propagate. So add
newMsg.clearMessage();
after
out.propagate(newAssembly);
The body in the output message should look like:
<Return>text</Return>
This is an example out of my head. So there could be one or two errors in it. But this example shows the way how to do it.
Regards,
Rainer |
|
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
|
|
|
|