Package org.apache.synapse.mediators.bsf
Interface ScriptMessageContext
- All Superinterfaces:
org.apache.synapse.MessageContext
- All Known Implementing Classes:
CommonScriptMessageContext,GraalVMJavaScriptMessageContext,NashornJavaScriptMessageContext,OpenJDKNashornJavaScriptMessageContext
public interface ScriptMessageContext
extends org.apache.synapse.MessageContext
ScriptMessageContext decorates the MessageContext interface by adding methods to use when
deals with message payload XML/Json, in a way natural to the scripting languages.
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a new SOAP header to the message.Get the XML representation of the complete SOAP envelope.Get the Message Payload as a text.Get the JSON object representation of the JSON message body of the request.Get the Message Payload as a text.Get the XML representation of SOAP Body payload.jsonObject(org.apache.synapse.MessageContext messageContext) Get the JSON object representation of the JSON message body of the request.voidremoveProperty(String key, String scope) Remove property from the message.voidsetFaultTo(String reference) This is used to set the value which specifies the receiver of the faults relating to the message.voidThis is used to set the value which specifies the sender of the message.booleansetJsonObject(org.apache.synapse.MessageContext messageContext, Object jsonObject) Saves the JavaScript Object to the message context.booleansetJsonText(org.apache.synapse.MessageContext messageContext, Object jsonObject) Saves the JSON String to the message context.voidsetPayloadJSON(Object jsonPayload) Saves the payload of this message context as a JSON payload.voidsetPayloadXML(Object payload) Set the SOAP body payload from XML.voidsetProperty(String key, Object value, String scope) Add a new property to the message.voidsetReplyTo(String reference) This is used to set the value which specifies the receiver of the replies to the message.voidsetScriptEngine(ScriptEngine scriptEngine) Set a script engine.voidThis is used to set the value which specifies the receiver of the message.Methods inherited from interface org.apache.synapse.MessageContext
getConfiguration, getContextEntries, getContinuationStateStack, getDefaultConfiguration, getEndpoint, getEntry, getEnvelope, getEnvironment, getFaultSequence, getFaultStack, getFaultTo, getFormat, getFrom, getLocalEntry, getMainSequence, getMessageFlowTracingState, getMessageID, getMessageString, getProperty, getPropertyKeySet, getRelatesTo, getReplyTo, getSequence, getSequenceTemplate, getServiceLog, getSoapAction, getTo, getTracingState, getVariable, getVariableKeySet, getWSAAction, getWSAMessageID, isContinuationEnabled, isDoingGET, isDoingMTOM, isDoingPOX, isDoingSWA, isFaultResponse, isResponse, isSOAP11, pushContinuationState, pushFaultHandler, restoreContinuationStateStack, setConfiguration, setContextEntries, setContinuationEnabled, setDoingGET, setDoingMTOM, setDoingPOX, setDoingSWA, setEnvelope, setEnvironment, setFaultResponse, setFaultTo, setFrom, setMessageFlowTracingState, setMessageID, setProperty, setRelatesTo, setReplyTo, setResponse, setSoapAction, setTo, setTracingState, setVariable, setWSAAction, setWSAMessageID
-
Method Details
-
getPayloadXML
Get the XML representation of SOAP Body payload. The payload is the first element inside the SOAP tags.- Returns:
- the XML SOAP Body
- Throws:
ScriptException- in-case of an error in getting the XML representation of SOAP Body payload
-
setPayloadXML
Set the SOAP body payload from XML.- Parameters:
payload- Message payload- Throws:
ScriptException- For errors in converting xml To OMorg.apache.axiom.om.OMException- For errors in OM manipulation
-
getPayloadJSON
Object getPayloadJSON()Get the JSON object representation of the JSON message body of the request.- Returns:
- JSON object of the message body
-
getJsonText
Object getJsonText()Get the Message Payload as a text.- Returns:
- Payload as text
-
getPayloadText
String getPayloadText()Get the Message Payload as a text.- Returns:
- Payload as text
-
setJsonObject
Saves the JavaScript Object to the message context.- Parameters:
messageContext- The message context of the sequencejsonObject- JavaScript Object which is passed to be saved in message context- Returns:
- true
-
setJsonText
Saves the JSON String to the message context.- Parameters:
messageContext- The message context of the sequencejsonObject- JavaScript string which is passed to be saved in message context- Returns:
- false if messageContext is null return true otherwise
-
jsonObject
Get the JSON object representation of the JSON message body of the request.- Returns:
- JSON object of the message body
-
setScriptEngine
Set a script engine.- Parameters:
scriptEngine- a ScriptEngine instance
-
addHeader
Add a new SOAP header to the message.- Parameters:
mustUnderstand- the value for thesoapenv:mustUnderstandattributecontent- the XML for the new header- Throws:
ScriptException- if an error occurs when converting the XML to OM
-
getEnvelopeXML
Get the XML representation of the complete SOAP envelope.- Returns:
- return an object that represents the payload in the current scripting language
- Throws:
ScriptException- in-case of an error in getting the XML representation of SOAP envelope
-
setTo
This is used to set the value which specifies the receiver of the message.- Parameters:
reference- specifies the receiver of the message
-
setFaultTo
This is used to set the value which specifies the receiver of the faults relating to the message.- Parameters:
reference- specifies the specifies the receiver of the faults relating to the message
-
setFrom
This is used to set the value which specifies the sender of the message.- Parameters:
reference- specifies the sender of the message
-
setReplyTo
This is used to set the value which specifies the receiver of the replies to the message.- Parameters:
reference- specifies the receiver of the replies to the message
-
setProperty
Add a new property to the message.- Parameters:
key- unique identifier of propertyvalue- value of propertyscope- scope of the property
-
removeProperty
Remove property from the message.- Parameters:
key- unique identifier of propertyscope- scope of the property
-
setPayloadJSON
Saves the payload of this message context as a JSON payload.- Parameters:
jsonPayload- Javascript native object to be set as the message body- Throws:
ScriptException- in case of creating a JSON object out of the javascript native object.
-