Author |
Message
|
mqqqqqq |
Posted: Tue Jan 31, 2012 5:05 am Post subject: Set SOAP body in Java |
|
|
Newbie
Joined: 31 Jan 2012 Posts: 6
|
Hello,
I need some java code that replicates this ESQL.
Code: |
SET OutputRoot.SOAP.Body = InputBody;
|
Help would be much appreciated!
(Using version 6.1) |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jan 31, 2012 5:32 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
mqqqqqq |
Posted: Tue Jan 31, 2012 5:43 am Post subject: |
|
|
Newbie
Joined: 31 Jan 2012 Posts: 6
|
So is there no way to create a new soap message using the incoming message body, and I will have to continue using ESQL?
I just need to be able to replicate whatever "SOAP.Body" does. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jan 31, 2012 5:50 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
mqqqqqq wrote: |
So is there no way to create a new soap message using the incoming message body, and I will have to continue using ESQL?
I just need to be able to replicate whatever "SOAP.Body" does. |
There's absolutely a way to do it.
You just have to write Java code to replicate whatever SOAP.Body does.
But that requires that you know what SOAP.Body does! Which is dead simple and easy.
There are lots of samples that come with the product, that provide Java source code examples of working with the message tree. |
|
Back to top |
|
 |
mqqqqqq |
Posted: Tue Jan 31, 2012 6:11 am Post subject: |
|
|
Newbie
Joined: 31 Jan 2012 Posts: 6
|
Perhaps I've already tried looking for an example in the documentation, and not found anything. And perhaps after that I looked on the web and still couldn't find an example?
I haven't signed up here in the past because of the rude, blunt and often unhelpful nature of these forums, but I have tried everything I can think of to solve this.
So please, if you have an example bit of code or can point me to the documentation that explains how to do it, I would really appreciate it. |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jan 31, 2012 6:39 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
mqqqqqq wrote: |
Perhaps I've already tried looking for an example in the documentation, and not found anything. And perhaps after that I looked on the web and still couldn't find an example?
I haven't signed up here in the past because of the rude, blunt and often unhelpful nature of these forums, but I have tried everything I can think of to solve this.
So please, if you have an example bit of code or can point me to the documentation that explains how to do it, I would really appreciate it. |
Perhaps the only things we know that you've done are the things that you've explicitly stated here?
Perhaps it's a mistake to assume a rude tone from plain unemphasized text.
I did point you directly at the documentation, for v6.1, that shows you how to COPY an element from one place to another.
The JavaComputeTransformXPath.java class includes a copyMessageHeaders method that should provide enough of a direct example to modify to suit your needs. EDIT: this is from the JavaCompute node sample projects.
There are better examples of this kind of thing in the v7 samples and in the v7 infocenter. And the code does still apply in v6.1 |
|
Back to top |
|
 |
mqqqqqq |
Posted: Tue Jan 31, 2012 7:21 am Post subject: |
|
|
Newbie
Joined: 31 Jan 2012 Posts: 6
|
Quote: |
Perhaps the only things we know that you've done are the things that you've explicitly stated here? |
Agreed. And the code I pasted here copies the incoming messages body to a new element Body within the SOAP domain.
Quote: |
Perhaps it's a mistake to assume a rude tone from plain unemphasized text. |
By saying its dead simple and easy, and referring me to the documentation with no further explanation of how that solves the problem I'm having implies either its a stupid question, or that I'm lazy and I've just come on here to leach information. Anyway, obviously I was mistaken in this and I apologize for reacting.
Quote: |
I did point you directly at the documentation, for v6.1, that shows you how to COPY an element from one place to another. |
I know how to copy a node. I copy and pasted that entire ESQL line because I thought it would give more context to what I was doing. To narrow it down more, the only thing what I want to do that I am unable to do is create this node, in Java:
Code: |
(0x01000000:Folder):SOAP = ( ['SOAP' : 0x5493fd8] |
I do not see any reference to ROOT_ELEMENT_NAME of type SOAP in the API. If I try and use XMLNSC I get a "no SOAP.Body" error message when trying to send a soap request node.
Anyway, I'll try find those examples; I've looked at the copyMessageHeaders method but I don't see how this helps.
[/quote] |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jan 31, 2012 8:01 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
To create a message that belongs to a domain, you need to use the form of create... that only takes a single argument, i.e.
Code: |
MbElement outBody = outRoot.createElementAsLastChild(MbXMLNSC.PARSER_NAME); |
But you need to indicate the name of the SOAP domain.
Try using the constant "SOAP". |
|
Back to top |
|
 |
mqqqqqq |
Posted: Wed Feb 01, 2012 6:51 am Post subject: |
|
|
Newbie
Joined: 31 Jan 2012 Posts: 6
|
Thanks. For anybody else wanting to know how to do this, all you need to do is detach the old body, then:
Code: |
MbElement soapRoot = outMessage.getRootElement().createElementAsLastChild("SOAP");
MbElement soapBody = soapRoot.createElementAsLastChild("SOAP");
soapBody.setName("Body");
|
Then reattach the old body to "soapBody". |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Feb 01, 2012 6:57 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You don't need to create the second element as the SOAP domain. It's already under the SOAP domain because it's the child of your SOAP domain element.
So you could just create the element using a different constructor and set the name at the same time. Or just detach/attach and/or copy the InputBody element instead.
Or you could skip building the tree in the SOAP domain, build only the body as an XMLNSC tree, and then use the SOAPEnvelope node to build the SOAP tree for you. |
|
Back to top |
|
 |
mqqqqqq |
Posted: Wed Feb 01, 2012 7:05 am Post subject: |
|
|
Newbie
Joined: 31 Jan 2012 Posts: 6
|
Thats what I thought but when I tried that, the Body node changed to the XMLNSC domain for some reason. |
|
Back to top |
|
 |
|