Building Your Event-Driven Architecture : Integration Server Built-In Services Reference : Flow Folder : Summary of Elements in this Folder : pub.flow:setResponse2
pub.flow:setResponse2
WmPublic. Forces a specified response to be returned by the webMethods Integration Server to a calling process (such as a browser or application server).
Formatting of the response is normally handled by templates, which format values from the pipeline. If templates are not appropriate for a particular integration scenario, a response message can be created within the flow and then returned to the caller using this service.
Input Parameters
responseString
String Optional. Response to be returned to the caller, specified as a string.
responseBytes
byte[ ] Optional. Response to be returned to the caller, specified as a byte array.
responseStream
java.io.InputStream Optional. Response to be returned to the caller, specified as an InputStream.
contentType
String Optional. MIME type of the response data. By default, the server's response will match the MIME type of the request. This field allows this behavior to be overridden.
Note:  
If you explicitly set this value with Designer, you will see two choices: text/XML and text/HTML. You are not limited to these two values. You may either select one of these or type a new value.
encoding
String Optional. Character set in which the response is encoded.
Output Parameters
None.
Usage Notes
This service replaces pub.flow:setResponse, which is deprecated.
Specify responseString, responseBytes, or responseStream. If you specify more than one, the pub.flow:setReponse2 service looks for the parameters in the following order and uses the first one that it finds: responseString, responseBytes,responseStream.
One possible usage of this service is to create an XML response to an XML request. A flow that creates an XML document by calling pub.xml:documentToXMLString can use pub.flow:setResponse2 to return the XML document to the caller. In your flow, you would map xmldata (output of pub.xml:documentToXMLString) to responseString and set contentType to text/xml (inputs to pub.flow:setResponse2). Calling pub.flow:setResponse2 will cause the server to return the XML document that you've mapped to responseString instead of processing the pipeline through a template.
Your client might be expecting binary data in the response, such as a JPEG image. In this case, map a byte array that represents the image to responseBytes and set contentType to image/jpeg.
Integration Server detects the type of request and sets the Content-Type value to text/XML (for requests in XML format) or text/HTML (for requests in all other formats). Be aware that if you specify a value for contentType, Designer will not able to decode or display output from flows that include this service. This is because your contentType setting will override the Content-Type value that the Integration Server uses to return output to Designer. If you use Run to test the flow, Designer will not display any results.
If you specify a contentType value that is not supported, Integration Server sets the Content-Type of the response to text/XML.
If the contentType input parameter and the Content-Type header of the request are not set, Integration Server uses the value of the request Accept header to set the Content-Type header of the response. For more information about how Integration Server handles Accept headers to set Content-Types, see webMethods Integration Server Administrator’s Guide.
Keep in mind that when returning the processed XML document to the client that originally submitted it, you may need to modify the encoding. Java String objects are always stored using a Unicode encoding. If your original XML document used an encoding other than UTF-8 or UTF-16, it will still contain an encoding tag that indicates what this encoding was. However, if you did not modify the encoding during document processing, you need to set the encoding parameter when you invoke the pub.flow:setResponse2 service. Specifically, do one of the following:
*Set the encoding parameter to match the tag in the file, or
*Set the encoding parameter to "autoDetect" to use the encoding specified in the XML string encoding tag.
Copyright © 2016 - 2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback