Ick...
Yea. You definitely would want to do that via a Stax wrapper. That
would perform a TON better.
Another option would be to configure in the SAAJ interceptor and prior
to the ending interceptor, modify the SAAJ model. That would avoid
the reparse to dom as it would already be in the dom.
The stax way would definitely be the most performant though.
Dan
On Aug 1, 2008, at 4:14 AM, adam_j_bradley wrote:
Based my work on
http://www.nabble.com/How-to-change-the-namespace-position-in-the-generate-xml-message-(SOAP-message)--to16176819.html#a16194931
I intercepted using the CachedOutputStream options (though if I had
my time
again I'd intercept at StaxOutInterceptor). Converted from string ->
DOM.
Removed the element and added a new CDATA node. I used JDOM for the
XPath
support.
---snip---
// Replace the text node with a CDATA node
Document document = null;
try {
SAXBuilder builder = new SAXBuilder(false);
document = builder.build(new InputSource(new
StringReader(tmpXML)));
Element root = document.getRootElement();
XPath xpath = XPath.newInstance("/descendant-or-
self::x:ppSoapHeader25");
xpath.addNamespace("x","http://schemas.microsoft.com/Passport/SoapServices/CredentialServiceAPI/V1
");
Element element = (Element) xpath.selectNodes(document).get(0);
// After
List parent = element.getParentElement().getChildren();
parent.remove(element);
// Add it again as CDATA
Element e = new Element("ppSoapHeader25");
e.addContent((new CDATA(element.getText())));
parent.add(e);
}
} catch (Exception e) {
System.out.println(e.toString());
}
// Push it back to tmpXML and into the OutputStream
XMLOutputter outputter = new XMLOutputter();
tmpXML = outputter.outputString(document);
---snip---
Brad-81 wrote:
Post it to the list and everyone can see it......magic :-)
On Tue, Jul 29, 2008 at 4:25 AM, adam_j_bradley
<[EMAIL PROTECTED]> wrote:
Ok, I now have it generating the CDATA entry as I'd hoped!
http://www.nabble.com/file/p18704319/2712837314_dae51ea53a_o.jpg
Drop me a line if you'd like to see know how :)
Adam
dkulp wrote:
I don't believe their is anyway to do this. I don't think the JAXB
runtime EVER calls writeCDATA of the Stax stuff. Most likely, you
should just remove the "<[CDATA[" and tailing "]]>" parts of the
string and just pass that. It will get escaped, but that SHOULD
be OK.
Dan
On Jul 28, 2008, at 1:13 AM, adam_j_bradley wrote:
I have a parameter I want to populate with CDATA but I'm having
trouble.
Currently the String is defined as
---snip---
String element = "!<[CDATA[<s:ppSoapHeader
xmlns:s=\"http://schemas.microsoft.com/Passport/SoapServices/SoapHeader
\"
version=\"1.0\"><s:lcid>1033</s:lcid><s:sitetoken><t:siteheader
xmlns:t=\"http://schemas.microsoft.com/Passport/SiteToken\" id=
\"" +
siteID
+ "\"/></s:sitetoken>" +
</s:ppSoapHeader>]]>";
---snip---
I wind up with
---snip---
!<[CDATA[<s:ppSoapHeader
xmlns:s="http://schemas.microsoft.com/Passport/SoapServices/
SoapHeader"version="1.0"><s:lcid>1033</
s:lcid><s:sitetoken><t:siteheader
xmlns:t="http://schemas.microsoft.com/Passport/SiteToken"
id="253988"/></s:sitetoken></s:ppSoapHeader>]]>
---snip---
But I want
---snip---
!<[CDATA[<s:ppSoapHeader
xmlns:s="http://schemas.microsoft.com/Passport/SoapServices/
SoapHeader"version="1.0"><s:lcid>1033</
s:lcid><s:sitetoken><t:siteheader
xmlns:t="http://schemas.microsoft.com/Passport/SiteToken"
id="253988"/></s:sitetoken><s:ppSoapHeader>]]>
---snip---
I don't want it to delimit the "<" with "<", expecially the one
before
the CDATA section!
Any ideas?
Thanks in advance!
Adam
--
View this message in context:
http://www.nabble.com/Q%3A-Marshall-CDATA-tp18684232p18684232.html
Sent from the cxf-user mailing list archive at Nabble.com.
---
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog
--
View this message in context:
http://www.nabble.com/Q%3A-Marshall-CDATA-tp18684232p18704319.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
View this message in context:
http://www.nabble.com/Q%3A-Marshall-CDATA-tp18684232p18770055.html
Sent from the cxf-user mailing list archive at Nabble.com.
---
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog