Access to raw stanza?

Issue #96 closed
Vitaly Takmazov created an issue

As I understand, now it is not possible to get raw stanza (except in XmppDebugger) So it isn't possible to create server session, for example, because it needs to forward raw stanzas with all unknown elements. Am I missing something?

Comments (12)

  1. Christian Schudt repo owner

    I am not sure, what you are trying to accomplish.

    You can use XmppSession.createMarshaller() and then marshall any element into an XML String, if you need that.

  2. Vitaly Takmazov reporter

    E.g. I have <message><body /><some-unknown-extension xmlns="..."/></message> and unknown extension will be lost when I will try to serialize Message back to XML string

  3. Christian Schudt repo owner

    I think JAXB deserializes unknown elements as org.w3c.dom.Element and also serializes Element to XML in a normal way.

  4. Christian Schudt repo owner

    Use XmppUtils.createXmppStreamWriter to create an XMLStreamWriter which doesn't write all these prefixes, like this:

                    XMLStreamWriter xmppStreamWriter = null;
                    try {
                        xmppStreamWriter = XmppUtils.createXmppStreamWriter(xmppSession.getConfiguration().getXmlOutputFactory().createXMLStreamWriter(byteArrayOutputStream));
                        xmppSession.createMarshaller().marshal(element, xmppStreamWriter);
                        xmppStreamWriter.flush();
                    } finally {
                        if (xmppStreamWriter != null) {
                            xmppStreamWriter.close();
                        }
                    }
    

    Here, an XMLStreamWriter is created from the session configuration, which is basically XMLOutputFactory.newFactory(). The writer then writes (marshalls) to an OutputStream.

    Just curious, what you are trying to do?

  5. Log in to comment