xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hacking Bear" <hackingb...@gmail.com>
Subject Re: Outputing XML beans
Date Wed, 06 Dec 2006 20:04:47 GMT
Doesn't work, still missing the <Request> tag.

Code changed:

        soapBody.getDomNode().appendChild(
                soapBody.getDomNode().getOwnerDocument().importNode(
request.getDomNode(), true));
        System.out.println("\nPrint soapDoc.save(OutputStream)");
        soapDoc.save(System.out);

Output:
Print soapDoc.save(OutputStream)
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><urn:AttributeQuery
xmlns:urn="urn:oasis:names:tc:SAML:1.0:protocol"><urn1:Subject
xmlns:urn1="urn:oasis:names:tc:SAML:1.0:assertion
"><urn1:NameIdentifier>NAME123</urn1:NameIdentifier></urn1:Subject></urn:AttributeQuery></soapenv:Body></soapenv:Envelope>

On 12/6/06, Alistair Young <alistair@smo.uhi.ac.uk> wrote:
>
> Is this any use to you? It inserts a SAML Request XMLBean into a SOAP
> XMLBean:
>
> soapBody.getDomNode().appendChild(soapBody.getDomNode
> ().getOwnerDocument().importNode(samlRequest.getDomNode(),
> true));
>
> Alistair
>
> --
> mov eax,1
> mov ebx,0
> int 80h
>
> > Hello,
> >
> > Can anyone help me on this?
> >
> > At least I want to know if it is a bug or by design that the top-most
> > element (e.g. the "Request" element in the example") are omitted. This
> > makes
> > it hard to write generic codes because one has to know the document type
> > to
> > wrap the xml bean object.
> >
> > Thanks
> >
> >
> >
> > On 12/4/06, Hacking Bear <hackingbear@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> I eventually can insert one XML bean into another using cursor. But
> >> still
> >> some question:
> >>
> >> 1. As experiment at point (A) and (B) below, it seems that XMLBean
> >> inserts
> >> the child after the cursor, rather than at the cursor, so I have to wrp
> >> it
> >> in a dummy doc or parent element. This also seems contradicting to the
> >> tutorial/document. Any idea why this is the case?
> >>
> >> 2. Is there a simpler API method that insert an XmlObject? Something
> >> like:
> >>        body.insert(XmlObject); // generated
> >>        cursor.insert(XmlObject); // cursor-based
> >>
> >> Thanks
> >>
> >> public class SOAPXBeanOutputTest {
> >>     public static void main(String[] args) throws Exception {
> >>         RequestType request = RequestType.Factory.newInstance();
> >>         request.setIssueInstant(Calendar.getInstance());
> >>         request.setRequestID ("REQ123");
> >>         AttributeQueryType query = request.addNewAttributeQuery();
> >>         SubjectType subject = SubjectType.Factory.newInstance();
> >>         NameIdentifierType nameId = subject.addNewNameIdentifier ();
> >>         nameId.setStringValue("NAME123");
> >>         query.setSubject((SubjectType)subject.copy());
> >>
> >>         EnvelopeDocument soapDoc =
> >> EnvelopeDocument.Factory.newInstance();
> >>         Envelope soapEnv = soapDoc.addNewEnvelope();
> >>         Body soapBody = soapEnv.addNewBody();
> >>
> >>         XmlCursor cursor = soapBody.newCursor();
> >>         cursor.toNextToken();
> >>
> >>         // (A) if not wrapping in dummy doc/element, results in output
> >> ...<soapenv:Body><urn:AttributeQuery...
> >>         RequestDocument dummyDoc =
> >> RequestDocument.Factory.newInstance();
> >>         dummyDoc.setRequest(request);
> >>
> >>         XmlCursor reqcursor = dummyDoc.newCursor(); // typs = STARTDOC
> >>         //reqcursor.toFirstChild(); // (B) this results in output
> >> ...<soapenv:Body><urn:AttributeQuery...
> >>         reqcursor.moveXmlContents(cursor);
> >>
> >>         reqcursor.dispose();
> >>         cursor.dispose();
> >>
> >>         soapDoc.save(System.out);
> >>     }
> >> }
> >>
> >>
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

Mime
View raw message