Class Message
Extends
CompositionItem.
Constructor Attributes | Constructor Name and Description |
---|---|
Message()
Represents a Message within the Composition.
|
Field Attributes | Field Name and Description |
---|---|
{integer} |
The number of bytes that were received.
|
{integer} |
The number of bytes that were sent.
|
{boolean} |
True if this Message had any validation failures.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to the
"getMessage" and "setMessage" methods.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to the
"getMessage" and "setMessage" methods.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to the
"getMessage" and "setMessage" methods.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
<constant> {integer} |
A constant that can be passed as the "indicator" parameter in calls to
the "getResponse" method.
|
{integer} |
The total amount of time, in milliseconds, that it took to send the
message and receive the response.
|
{integer} |
The number of retries that were required due to unavailable local ports
when sending the message.
|
{integer} |
The total amount of time, in milliseconds, that was spent retrying due to
unavailable local ports when sending the message.
|
{Target} |
The Target object for this Message.
|
{integer} |
The "time to first byte" measurement for this message.
|
{integer} |
The "time to last byte" measurement for this message.
|
{String} |
The value "Message".
|
- Fields borrowed from class CompositionItem:
- children, completionType, failureText, forEachValue, hasErrorEvents, index, name, nextItem, parent, path, playNumber, playNumberBeforeRenewal, playNumberWithinRenewal, previousItem, propertyList, REPEAT_DISTRIBUTION_CONSTANT, REPEAT_TIMING_PARALLEL, REPEAT_TIMING_SERIAL, REPEAT_TYPE_COUNT_CONSTANT, repeatIndex, systemPropertyList
Method Attributes | Method Name and Description |
---|---|
Clears any current response from memory.
|
|
{String} |
getMessage(messageFieldIndicator)
Returns all or the specified portion of the message that is to be sent.
|
{String[]} |
If the response to this Message is HTML, the HTML is parsed and any
links on the HTML page to external resources are extracted and returned
as an array of URLs.
|
{Object} |
getResponse(responseFieldIndicator, param)
Returns all or the specified portion of the response, if a response has
been received.
|
setMessage(value, messageFieldIndicator)
Sets all or the specified portion of the message that is to be sent.
|
- Methods borrowed from class CompositionItem:
- clearRepeat, end, endRepeat, getChild, getItemViaPath, setRepeat
Read only.
Read only.
False until the Message plays. If the Message never plays, remains false.
Read only.
- Since:
- Build 5618
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Read only.
Can be used after the Message plays to free up the memory used to hold the response if the Message does not have scope "private".
If the Mesage has scope private, this call is not necessary, since the memory will be freed automatically by the system when it goes out of scope.
The indicator values that are permitted, and the type and format of the information returned, depends upon the type of the Message's Target. The type of the Target is set at the time the Target is created, through the "Target Creation Wizard", Clip generation from a Recording, or through a manual creation process. The types of Targets are: WSDL, HTTP, WebUI/Ajax, JMS, and REST. (Note that types JMS and REST cannot currently be created through the Target Editor and can only be created through a manual creation process by SOASTA Support.) Targets of type WebUI/Ajax cannot be used with Messages (they are used with Browser Actions only) and thus are not applicable here.
The "indicator" parameter must be one of the following:
- MESSAGE_TEXT
Returns a representation of the entire message that is to be sent.
Permitted for: JMS.
Not permitted for: WSDL, HTTP, REST.
- MESSAGE_HTTP_BODY
Returns an XML representation of the body of the message that is to be sent.
Permitted for: WSDL, HTTP, REST.
Not permitted for: JMS.
- MESSAGE_HTTP_HEADERS
The current value of the (optional) HTTP headers to be sent with the message is returned. A text string is returned with new-lines between the HTTP headers. Will be null if there are no HTTP headers.
Permitted for: WSDL, HTTP, REST.
Not permitted for: JMS.
If the "indicator" parameter is omitted, null or undefined, "MESSAGE_HTTP_BODY" will be assumed for all types other than JMS. For JMS, "MESSAGE_TEXT" will be assumed.
Example of the XML returned for indicator "MESSAGE_TEXT" for JMS Targets:
<Content xmlns="http://www.soasta.com/services/repository">
<JMS xmlns="http://www.soasta.com/services/repository">
<Mapped xmlns="http://www.soasta.com/services/repository">
<Field name="Field1 string" type="string" xmlns="http://www.soasta.com/services/repository">Base64 test value</Field>
<Field name="Field2 boolean" type="boolean" xmlns="http://www.soasta.com/services/repository">false</Field>
<Field name="Field3 byte" type="byte" xmlns="http://www.soasta.com/services/repository">23</Field>
<Field name="Field4 short" type="short" xmlns="http://www.soasta.com/services/repository">234</Field>
<Field name="Field5 int" type="int" xmlns="http://www.soasta.com/services/repository">2345</Field>
<Field name="Field6 long" type="long" xmlns="http://www.soasta.com/services/repository">23456</Field>
<Field name="Field7 float" type="float" xmlns="http://www.soasta.com/services/repository">234.567</Field>
<Field name="Field8 double" type="double" xmlns="http://www.soasta.com/services/repository">765.432</Field>
<Field name="Field9 bytes" type="base64Binary" xmlns="http://www.soasta.com/services/repository">QmFzZTY0IHRlc3QgdmFsdWU=</Field>
</Mapped>
<Properties xmlns="http://www.soasta.com/services/repository">
<Property name="Prop1$string" type="string" value="Message 1, Prop1, string" xmlns="http://www.soasta.com/services/repository"/>
<Property name="Prop2$boolean" type="boolean" value="true" xmlns="http://www.soasta.com/services/repository"/>
<Property name="Prop3$byte" type="byte" value="12" xmlns="http://www.soasta.com/services/repository"/>
<Property name="Prop4$short" type="short" value="123" xmlns="http://www.soasta.com/services/repository"/>
<Property name="Prop5$int" type="int" value="1234" xmlns="http://www.soasta.com/services/repository"/>
<Property name="Prop6$long" type="long" value="12345" xmlns="http://www.soasta.com/services/repository"/>
<Property name="Prop7$float" type="float" value="123.456" xmlns="http://www.soasta.com/services/repository"/>
<Property name="Prop8$double" type="double" value="654.321" xmlns="http://www.soasta.com/services/repository"/>
</Properties>
<Headers xmlns="http://www.soasta.com/services/repository">
<CorrelationID value="Message 1A correlation ID" xmlns="http://www.soasta.com/services/repository"/>
<Type value="Message 1A Type" xmlns="http://www.soasta.com/services/repository"/>
<DeliveryMode value="1" xmlns="http://www.soasta.com/services/repository"/>
<Expiration value="100000000" xmlns="http://www.soasta.com/services/repository"/>
<Priority value="9" xmlns="http://www.soasta.com/services/repository"/>
</Headers>
</JMS>
</Content>
Example of the XML returned for indicator "MESSAGE_HTTP_BODY" for HTTP Targets:
<Content xmlns="http://www.soasta.com/services/repository">
<HTTPCommon xmlns="http://www.soasta.com/services/repository">
<Headers xmlns="http://www.soasta.com/services/repository">Host: confidence.soasta.com
Origin: http://confidence.soasta.com
Accept-Language: en-us
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png;q=0.5
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-us) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4
Accept-Encoding: gzip, deflate
Referer: http://confidence.soasta.com/concerto/Login
Content-Type: application/x-www-form-urlencoded
Proxy-Connection: keep-alive
Connection: keep-alive
Pragma: no-cache
</Headers>
</HTTPCommon>
<REST verb="POST" xmlns="http://www.soasta.com/services/repository">
<Location xmlns="http://www.soasta.com/services/repository">/concerto/Login</Location>
<Document xmlns="http://www.soasta.com/services/repository">goto=&userName=Fred&password=pw</Document>
</REST>
</Content>
If the data to be sent is binary, the data in the "Document" tag will be Base 64 encoded, and the attribute base64Encoded="true" will be present on that tag.
Example of the XML returned for indicator "MESSAGE_HTTP_BODY" for REST Targets:
<Content xmlns="http://www.soasta.com/services/repository">
<REST xmlns="http://www.soasta.com/services/repository">
<Params xmlns="http://www.soasta.com/services/repository">string=%7B%22ResultSet%22:%7B%22Result%22:%22lincoln%22%7D%7D</Params>
<Location xmlns="http://www.soasta.com/services/repository">/DevTest/echoString</Location>
</REST>
</Content>
For WSDL Targets, the message's SOAP XML is returned for indicator "MESSAGE_HTTP_BODY", as in the following example:
<soapenv:Envelope xmlns:ns="http://www.soasta.com/services" xmlns:ns1="http://webservice.maestrotestservice.testservices.soasta.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns:testOutput><!-- minOccurs=1 maxOccurs=1 -->
<ns:inputValue1>aaa</ns:inputValue1><!-- minOccurs=1 maxOccurs=1 -->
<ns:inputValue2>bbb</ns:inputValue2><!-- minOccurs=1 maxOccurs=1 -->
<ns:inputValue3>ccc</ns:inputValue3><!-- minOccurs=1 maxOccurs=1 -->
<ns:inputValue4>ddd</ns:inputValue4><!-- minOccurs=1 maxOccurs=1 -->
<ns:inputValue5>eee</ns:inputValue5>
</ns:testOutput>
</soapenv:Body>
</soapenv:Envelope>
- Parameters:
- {integer} messageFieldIndicator Optional
An indicator as to what is to be returned.
- Returns:
- {String}
The requested portion of the Message to be sent.
If there is no response, or the response is not HTML, null is returned.
- Returns:
- {String[]}
Array of URL strings.
The meaning of the "param" parameter depends upon the value of the "indicator" parameter. The "indicator" parameter must be one of the following:
- RESPONSE_TEXT
Returns the entire text of the response received as a string. The "param" parameter is not used.
- RESPONSE_HTTP_BODY
Returns the body of the HTTP response received as a string. The "param" parameter is not used. This indicator value is valid only for responses that are HTTP-based.
- RESPONSE_HTTP_STATUSTEXT
Returns the status text from the HTTP response received as a string. The "param" parameter is not used. This indicator value is valid only for responses that are HTTP-based.
- RESPONSE_HTTP_HEADER
Returns one HTTP header from the response received as a string. The "param" parameter is the name of the HTTP header to be returned. If the response contains no HTTP header with the specified name, null is returned. This indicator value is valid only for responses that are HTTP-based.
- RESPONSE_HTTP_HEADER_LIST
Returns a list of all HTTP headers in the response. The "param" parameter is not used.
The return value is an array of Objects. Each object has two String property values: "name" (the name of the HTTP header) and "value" (the value of the HTTP header). If an HTTP header appears more than once in the response, it will appear that many times in the array. The items in the array are not in any particular order.
Here's an example of a Script that gets all HTTP headers from the response to the Message before the Script and outputs the list to the Result:
var msg = $context.currentItem.previousItem; var headerList = msg.getResponse(msg.RESPONSE_HTTP_HEADER_LIST); if (headerList == null) { $context.result.postMessage($context.result.LEVEL_INFO, "No headers."); } else { var listAsText = ""; for each (var header in headerList) { listAsText += "Name: " + header.name + ", Value: " + header.value + "\n"; } $context.result.postMessage($context.result.LEVEL_INFO, headerList.length + " HTTP headers", listAsText); }
- RESPONSE_HTTP_PROTOCOL
Returns the protocol value from the HTTP response received as a string. The "param" parameter is not used. This indicator value is valid only for responses that are HTTP-based.
- RESPONSE_HTTP_STATUSCODE
Returns the status code from the HTTP response received as a string. The "param" parameter is not used. This indicator value is valid only for responses that are HTTP-based.
- RESPONSE_TEXT_AS_XML
Parses the entire response text as XML, evaluates an XPath expression for that XML, and returns the result of that XPath expression. The "param" parameter contains the XPath expression. This indicator value is valid only for responses that are not HTTP-based. If no nodes in the XML match, null is returned. If there are one or more matching nodes, a string array is returned. (An array is returned even if there is only one match.)
- RESPONSE_TEXT_AS_HTML
Parses the entire response text as HTML, evaluates an XPath expression for that HTML, and returns the result of that XPath expression. The "param" parameter contains the XPath expression. This indicator value is valid only for responses that are not HTTP-based. If no nodes in the HTML match, null is returned. If there are one or more matching nodes, a string array is returned. (An array is returned even if there is only one match.)
- RESPONSE_TEXT_AS_JSON
Parses the entire response text as JSON, evaluates an XPath expression for that XML, and returns the result of that XPath expression. The "param" parameter contains the XPath expression. This indicator value is valid only for responses that are not HTTP-based. If no item in the JSON match, null is returned. If there are one or more matching nodes, a string array is returned. (An array is returned even if there is only one match.)
- RESPONSE_TEXT_WITH_JSONPATH
Processes the entire response text assuming it is JSON, evaluates a JSONPath expression for that JSON, and returns the result of that JSONPath expression. The "param" parameter contains the JSONPath expression. This indicator value is valid only for responses that are not HTTP-based. If no item in the JSON matches, null is returned. If there are one or more matching nodes, a string array is returned. (An array is returned even if there is only one match.)
- RESPONSE_HTTP_BODY_AS_XML
Parses the body of the HTTP response received as XML, evaluates an XPath expression for that XML, and returns the result of that XPath expression. The "param" parameter contains the XPath expression. This indicator value is valid only for responses that are HTTP-based. If no nodes in the XML match, null is returned. If there are one or more matching nodes, a string array is returned. (An array is returned even if there is only one match.)
- RESPONSE_HTTP_BODY_AS_HTML
Parses the body of the HTTP response received as HTML, evaluates an XPath expression for that HTML, and returns the result of that XPath expression. The "param" parameter contains the XPath expression. This indicator value is valid only for responses that are HTTP-based. If no nodes in the HTML match, null is returned. If there are one or more matching nodes, a string array is returned. (An array is returned even if there is only one match.)
- RESPONSE_HTTP_BODY_AS_JSON
Parses the body of the HTTP response received as JSON, evaluates an XPath expression for that JSON, and returns the result of that XPath expression. The "param" parameter contains the XPath expression. This indicator value is valid only for responses that are HTTP-based. If no items in the JSON match, null is returned. If there are one or more matching nodes, a string array is returned. (An array is returned even if there is only one match.)
- RESPONSE_HTTP_BODY_WITH_JSONPATH
Processes the body of the HTTP response assuming it is JSON, evaluates a JSONPath expression for that JSON, and returns the result of that JSONPath expression. The "param" parameter contains the JSONPath expression. This indicator value is valid only for responses that are HTTP-based. If no items in the JSON match, null is returned. If there are one or more matching nodes, a string array is returned. (An array is returned even if there is only one match.)
- Parameters:
- {integer} responseFieldIndicator Optional, Default: RESPONSE_TEXT
Indicator of what is to be returned.
- {String | String[]} param Optional
Depends upon the value of responseFieldIndicator.
- Returns:
- {Object}
Depending upon the situation, either null, String or array of String.
The "value" parameter is the value (as a text string) to be placed into the message. See the description of the getMessage method, for descriptions of the formats required for this value for each of the Target types and "indicator" values.
The indicator values that are permitted, and the type and format of the information required, depends upon the type of the Message's Target. The type of the Target is set at the time the Target is created, through the "Target Creation Wizard", Clip generation from a Recording, or through a manual creation process. The types of Targets are: WSDL, HTTP, WebUI/Ajax, JMS, and REST. (Note that types JMS and REST cannot currently be created through the Target Editor and can only be created through a manual creation process by SOASTA Support.) Targets of type WebUI/Ajax cannot be used with Messages (they are used with Browser Actions only) and thus are not applicable here.
The "indicator" parameter must be one of the following:
- MESSAGE_TEXT
"value" must contain a representation of the entire message that is to be sent, in the format described in getMessage, above.
Permitted for: JMS.
Not permitted for: WSDL, HTTP, REST.
- MESSAGE_HTTP_BODY
"value" must contain an XML representation of the body of the message that is to be sent, in the format described in getMessage, above.
Permitted for: WSDL, HTTP, REST.
Not permitted for: JMS.
Note that setting the headers through this call will also affect the headers set using the MESSAGE_HTTP_HEADERS indicator.
- MESSAGE_HTTP_HEADERS
"value" must contain the list of HTTP headers to be sent. It must be a text string with new-lines between the headers. It can be null to specify that there are no HTTP headers.
Permitted for: WSDL, HTTP, REST.
Not permitted for: JMS.
Note that setting the headers through this call will also affect the headers set using the MESSAGE_HTTP_BODY indicator.
If the "indicator" parameter is omitted, null or undefined, "MESSAGE_HTTP_BODY" will be assumed for all types other than JMS. For JMS, "MESSAGE_TEXT" will be assumed
- Parameters:
- {object} value
The value that is to be placed into the Message.
- {object} messageFieldIndicator Optional
An indication of what portion of the Message is to be set.