Author |
Message
|
gopi.balagala |
Posted: Tue May 21, 2013 11:08 pm Post subject: Java Compute Node with SoapInput Node |
|
|
Newbie
Joined: 21 May 2013 Posts: 6
|
Hi,
I am very new to Message Broker,
I have developed one simple application with soap nodes.
1). Soapinput node to compute node(caculate values) and send response to SoapReply. Its working fine.
2). Same I tried with Java compute node with Soapinput, here what ever I am giving request in response also same coming, I didn't get caculated values, below of the java compute node code:
Compute Node Code:
-----------------------------
Code: |
public void evaluate(MbMessageAssembly assembly)throws MbException{
MbOutPutterminal out = getOutputTerminal("out");
MbOutputTerminal alt = getOutputTerminal("alternate");
MbMessage message = assembly.getMessage();
MbMessage outMessage = new MbMessage();
// Add user code below
MbMessage inMessage = assembly.getMessage();
MbElement root = inMessage.getRootElement();
String firstElement = root.getLastchild().getFirstChild().getFirstChild().getValueAsString();
Strubg secondElement = root.getLastChild().getFirstChild().getLastChild().getValueAsString();
int a = Integer.parseInt(firstElement);
int b = Integer.parseInt(secondElement);
int c = a + b;
String output = ""+c;
MbElement outRoot = outMessage.getRootElement();
MbElement messageRoot = outRoot.createElementAsLastChild("XMLNSC");
MbElement outPut = messageRoot.createElementAsLAstChild(MbXMLNSC.FOLDER, "TOTAL", null);
output.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"Final Value", output);
//End of user code
out.propagate(assembly);
} |
-------------------------------------
Can you please help me any one what I did mistake.
Thanks,
Gopi. |
|
Back to top |
|
 |
gopi.balagala |
Posted: Tue May 21, 2013 11:10 pm Post subject: Request and Response in Soap UI |
|
|
Newbie
Joined: 21 May 2013 Posts: 6
|
and this is request soapinput xml file:
--------------------------------------
Code: |
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ws="http://ws.myeclipseide.com/">
<soapenv:Header/>
<soapenv:Body>
<ws:add>
<arg0>10</arg0>
<arg1>5</arg1>
</ws:add>
</soapenv:Body>
</soapenv:Envelope> |
------------------------------
in response also same coming,
output Response:
-------------------------
Code: |
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<NS1:add xml:NS1="http://ws.myeclipseide.com/">
<arg0>10</arg0>
<arg1>5</arg1>
</NS1:add>
</soapenv:Body>
</soapenv:Envelope> |
-----------------------
Same comig, pls help me any one. |
|
Back to top |
|
 |
Esa |
Posted: Tue May 21, 2013 11:17 pm Post subject: Re: Java Compute Node with SoapInput Node |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
gopi.balagala wrote: |
Code: |
public void evaluate(MbMessageAssembly assembly)throws MbException{
...
out.propagate(assembly);
} |
|
You are propagating the input assembly... |
|
Back to top |
|
 |
gopi.balagala |
Posted: Tue May 21, 2013 11:23 pm Post subject: |
|
|
Newbie
Joined: 21 May 2013 Posts: 6
|
Hi Esa,
out.propagate(assembly);
Instead of this what I have to add here.
Thanks,
Gopi. |
|
Back to top |
|
 |
Esa |
Posted: Tue May 21, 2013 11:43 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
Create a dummy JCN in a flow, click Open Java and run the wizard with various options. Examine differences between the generated code snippets and you will get the idea. |
|
Back to top |
|
 |
nukalas2010 |
Posted: Tue May 21, 2013 11:56 pm Post subject: |
|
|
 Master
Joined: 04 Oct 2010 Posts: 220 Location: Somewhere in the World....
|
gopi.balagala wrote: |
Hi Esa,
out.propagate(assembly);
Instead of this what I have to add here.
Thanks,
Gopi. |
Instead of this, you have to pass as
Code: |
out.propagate(outRoot ); |
 |
|
Back to top |
|
 |
Esa |
Posted: Wed May 22, 2013 12:16 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
nukalas2010 wrote: |
Instead of this, you have to pass as
Code: |
out.propagate(outRoot ); |
 |
Sorry, nukalas2010, but that is wrong answer  |
|
Back to top |
|
 |
gopi.balagala |
Posted: Wed May 22, 2013 12:21 am Post subject: |
|
|
Newbie
Joined: 21 May 2013 Posts: 6
|
Yes, I tried its showing error,
Still I am searching to my out put.
If u have any answer please reply me.
Thanks,
Gopi. |
|
Back to top |
|
 |
gopi.balagala |
Posted: Wed May 22, 2013 12:34 am Post subject: |
|
|
Newbie
Joined: 21 May 2013 Posts: 6
|
Thanks a lot for good repsonse,
Finally I resolved the issue.
I didn't created in my code outAssembly,
Just I added its getting exact response.
Thanks,
Gopi. |
|
Back to top |
|
 |
gopi.balagala |
Posted: Wed May 22, 2013 12:40 am Post subject: |
|
|
Newbie
Joined: 21 May 2013 Posts: 6
|
Code: |
out.propagate(outAssembly); |
Thanks,
Gopi. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed May 22, 2013 11:28 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Set a breakpoint between the input node and the JCN.
Look at the message tree (representing your InputRoot or InMessage.)
Remember WMB Message is quite different from SOAP Message.
The SOAP Message is at best a subset of the WMB Message.
You will then see why your
Code: |
String firstElement = root.getLastchild().getFirstChild().getFirstChild().getValueAsString(); |
is so wrong. This will show you the value of the first element of the header?
I am thinking here InputRoot.SOAP.Header....
And think that namespaces are often handled before the actual value and as such are children of the node they are actually declared in...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
nukalas2010 |
Posted: Thu May 23, 2013 3:57 am Post subject: |
|
|
 Master
Joined: 04 Oct 2010 Posts: 220 Location: Somewhere in the World....
|
Esa wrote: |
nukalas2010 wrote: |
Instead of this, you have to pass as
Code: |
out.propagate(outRoot ); |
 |
Sorry, nukalas2010, but that is wrong answer  |
sorry sorry for the wrong answer.. we should send like below..
Code: |
MbMessageAssembly o u t A s s embly = new MbMessageAssembly(i n A s s e m b l y, outRoot);
out.propagate(outAssembly); |
|
|
Back to top |
|
 |
|