Code Snippets
Using the Action Context Object
A good way to figure out the contents of the Action Context is to turn debugging on and put a break point in the execute method. For information on how to turn debugging on, see the Debugging and Logging.
It is useful to inspect the contents of the following objects to know everything you have at your disposal:
- _contextDocumentsByQName
- _contextObjectsByQName
- _contextPropertiesByQName
Extracting the SOAP envelope in Custom Action’s execute method
Here is a code snippet to extract and parse the message payload when your
action.execute()
method is invoked. The code snippet is written assuming that the payload is a soap envelope:
org.w3c.dom.Document envelope = (Document)( actionContext.getDocument(ActionConstants.MESSAGE_ENVELOPE)); if (envelope != null) { String envelopeString = com.tibco.governance.agent.core.utils.DOMUtils.getInstance().getString(envelope)); Element soapBody = DOMUtils.getFirstDescendantElementNS(envelope.getDocumentElement(), "http://schemas.xmlsoap.org/soap/envelope/", "Body"); String soapBodyString = DOMUtils.getInstance().getString(soapBody);