Thilina,
So the following code should work?
boolean binary = false;
OMElement theElement...
OMNode theNode =
theElement.getFirstOMChild();
if (theNode.getType() == OMNode.TEXT_NODE)
{
OMText theText =
(OMText) theNode;
if (theText.isBinary() {
// base64Binary: could
be base64 encoded in soap body or mime attachment, how do I know the
difference or should it even matter?
binary =
true;
DataHandler dh =
theText.getDataHandler();
InputStream stream =
dh.getDataSource().getInputStream();
...
}
}
if (!binary) {
// then process the child nodes of theElement
as plain xml
...
}
Thank
you for your insight.
From: Thilina Gunarathne [mailto:[EMAIL PROTECTED]
Sent: Saturday, October 21, 2006 2:25 AM
To: [email protected]
Cc: [email protected]
Subject: Re: MTOM
Hi,From: Thilina Gunarathne [mailto:[EMAIL PROTECTED]
Sent: Saturday, October 21, 2006 2:25 AM
To: [email protected]
Cc: [email protected]
Subject: Re: MTOM
You would be able to handle the case2 & 3 without much hassle.. In the case2 you have to explicitly set that the content is base64Binary. If not Axis2 will treat it as a normal string. You can do that either by using a schema which defines that the content of the "output" element is base64Binary or you can explicitly set that by setting the "setBinary(true);" in that text node.
Following modified code will handle both case 2 & 3..
OMElement outputElement ...
OMNode node = outputElement.getFirstOMChild();
if (node.getType() == OMNode.TEXT_NODE) {
OMText text = (OMText) node;
test.setBinary(true);
DataHandler dh = text.getDataHandler();
InputStream stream = dh.getDataSource().getInputStream();
}
Is dh valid for case (2) as well? or is dh=null in this case? I can test text.isOptimized() to see if base64 encoded? How can I know if its plain xml?
If the node is an instance of OMElement then it's a piece of xml.. You can also test for node.getType() == OMNode.ELEMENT_NODE...
Thanks,
~Thilina
Maybe text.isBinary ()...
Thanks for any suggestions.
Tony Dean
SAS Institute Inc.
919.531.6704
[EMAIL PROTECTED]
SAS... The Power to Know
http://www.sas.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
http://webservices.apache.org/~thilina/
http://thilinag.blogspot.com/
