com.bea.wsrp.ext.holders
Class XmlPayload

java.lang.Object
  extended by com.bea.wsrp.ext.holders.XmlPayload
All Implemented Interfaces
Serializable

public class XmlPayload
extends Object
implements Serializable

This class can be used to add XML payload for custom data transport and events.

When used for event payloads over WSRP 2.0, the XmlPayload object is marshalled into the WSRP event payload in the SOAP message directly, and any WSRP 2.0 event payloads that WLP does not know how to convert into a native Java object are represented as XmlPayload objects.

For transporting custom data, instead of using MarkupRequestState, MarkupResponseState, InteractionRequestState or InteractionResponseState interfaces, you can send/receive an instance of this class.

Here is an example.

       Element xml = ... // Create this element. This represents your payload.
       XmlPayload payload = new XmlPayload(xml);
       httpRequest.setAttribute(MarkupRequestState.KEY, payload); // Send the xml payload
   

You can also use this class for transporting XML as payload with custom events.

Here is an example.

       // Create payload
       XmlPayload xmlPayload = new XmlPayload(someDomElement);

       // Fire an event
       HttpServletRequest httpRequest = (HttpServletRequest) actionRequest.getAttribute("javax.servlet.request");
       PortletBackingContext backingContext = PortletBackingContext.getPortletBackingContext(httpRequest);
       backingContext.fireCustomEvent("xmlPayloadEvent", xmlPayload);
 

XML elements supplied to this class without a namespace will inherit the namespace of the wrapping elements in the SOAP message, which is subjected to change. To avoid conflicting with namespaces declared in the WSRP protocol (and WLP extensions), please consider declaring the XML payload in a seperate application namespace. For WSRP 2.0 this is required by the schema.

See Also
Serialized Form

Constructor Summary
XmlPayload()
          Creates an instance without the XML payload.
XmlPayload(Element payload)
          Creates an instance with an XML payload.
XmlPayload(Element payload, QName type)
          Creates an instance with an XML payload and the specified XML type.
 
Method Summary
 Element getPayload()
          Returns the XML payload as an element.
 QName getType()
          Returns the XML type of this XmlPayload, if set.
 void setPayload(Element payload)
          Sets the XML payload as an element.
 void setType(QName type)
          Sets the XML type of this XmlPayload, to be used in the WSRP event metadata if the XmlPayload is used as an event payload.
 String toString()
          Returns the XML this XmlPayload object's DOM element represents as a somewhat normalized string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlPayload

public XmlPayload()
Creates an instance without the XML payload.


XmlPayload

public XmlPayload(Element payload)
Creates an instance with an XML payload. The given payload element will be copied into the SOAP message during serialization.

Parameters
payload -

XmlPayload

public XmlPayload(Element payload,
                  QName type)
Creates an instance with an XML payload and the specified XML type. The given payload element will be copied into the SOAP message during serialization, and the type will be included in the event metadata if this is used as an event payload.

Parameters
payload -
Method Detail

getPayload

public Element getPayload()
Returns the XML payload as an element.

Returns
payload

setPayload

public void setPayload(Element payload)
Sets the XML payload as an element.

Parameters
payload -

setType

public void setType(QName type)
Sets the XML type of this XmlPayload, to be used in the WSRP event metadata if the XmlPayload is used as an event payload.

Parameters
type - the XML type

getType

public QName getType()
Returns the XML type of this XmlPayload, if set.

Returns
the XML type of the XmlPayload, or null if not set.

toString

public String toString()
Returns the XML this XmlPayload object's DOM element represents as a somewhat normalized string. This is a somewhat costly operation, so should be used only when necessary.

Overrides:
toString in class Object


Copyright © 2011, Oracle. All rights reserved.