java.lang.Object
org.cybergarage.http.HTTPPacket
org.cybergarage.http.HTTPResponse
org.cybergarage.soap.SOAPResponse
- Direct Known Subclasses:
ControlResponse
Represents a SOAP (Simple Object Access Protocol) response message.
This class extends HTTPResponse to handle SOAP protocol responses used in UPnP control operations. It provides functionality for creating and parsing SOAP responses with proper XML formatting and envelope structure.
Key features:
- SOAP envelope and body creation
- XML content management
- UTF-8 encoding support
- HTTP response integration
- Fault message handling
This class is used by UPnP devices to send action invocation responses to control points, enabling structured XML responses through SOAP messaging over HTTP.
Field Summary
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty response carrying a fresh SOAP envelope body.SOAPResponse(HTTPResponse httpRes) Copies the connection state of an HTTP response, replacing its payload with an empty SOAP envelope.SOAPResponse(SOAPResponse soapRes) Adopts the envelope node of another SOAP response.Method Summary
Modifier and TypeMethodDescriptionGet the SOAP body node.Get the SOAP envelope node.Get the SOAP fault actor string.Get the SOAP fault actor node.Get the SOAP fault code string.Get the SOAP fault code node.Get the SOAP fault detail node.Get the SOAP fault node.Get the SOAP fault string.Get the SOAP fault string node.getMethodResponseNode(String name) Get the method response node for the given name.private NodeThe SOAP body's root node.voidprint()Writes the response to the debug log, as text or as its root element.voidsetContent(Node node) Set the content from an XML node.voidsetEnvelopeNode(Node node) Set the SOAP envelope node.private voidsetRootNode(Node node) Sets the SOAP body's root node.Methods inherited from class HTTPResponse
getHeader, getStatusCode, getStatusLineString, isSuccessful, setStatusCode, toStringModifier and TypeMethodDescriptionReturn the full header string for this HTTP response.intGets the HTTP status code of this response.Gets the status line string of this HTTP response.booleanChecks if this response has a successful status code.voidsetStatusCode(int code) Sets the HTTP status code of this response.toString()/////////////////////////////////////////////Methods inherited from class HTTPPacket
addHeader, addHeader, clearHeaders, getCacheControl, getCharSet, getConnection, getContent, getContentInputStream, getContentLanguage, getContentLength, getContentRange, getContentRangeFirstPosition, getContentRangeInstanceLength, getContentRangeLastPosition, getContentString, getContentType, getDate, getFirstLine, getFirstLineToken, getHeader, getHeader, getHeaderString, getHeaderValue, getHost, getIntegerHeaderValue, getLongHeaderValue, getNHeaders, getServer, getStringHeaderValue, getStringHeaderValue, getTransferEncoding, getVersion, hasConnection, hasContent, hasContentInputStream, hasContentRange, hasFirstLine, hasHeader, hasTransferEncoding, init, isChunked, isCloseConnection, isKeepAliveConnection, read, set, set, set, set, setCacheControl, setCacheControl, setCacheControl, setConnection, setContent, setContent, setContent, setContent, setContentInputStream, setContentLanguage, setContentLength, setContentRange, setContentType, setDate, setHeader, setHeader, setHeader, setHeader, setHost, setIntegerHeader, setLongHeader, setServer, setStringHeader, setStringHeader, setTransferEncoding, setVersionModifier and TypeMethodDescriptionvoidAdds a header with the specified name and value.voidaddHeader(HTTPHeader header) Adds a header to this HTTP packet.voidClears all headers from this HTTP packet.Get the Cache-Control header value.Gets the character set from the Content-Type header.Gets the Connection header value.byte[]Gets the content of this HTTP packet.Gets the content input stream.Gets the Content-Language header value.longGets the content length from the Content-Length header.long[]Gets the content range values as an array.longGet the first position from the content range.longGet the instance length from the content range.longGet the last position from the content range.Gets the content of this HTTP packet as a string.Gets the Content-Type header value.getDate()Get the Date header value.protected StringGets the first line of the HTTP packet.protected StringgetFirstLineToken(int num) Gets a specific token from the first line using HTTP request line delimiters.getHeader(int n) Gets the header at the specified index.Gets the header with the specified name, ignoring case.Gets all headers as a formatted string.getHeaderValue(String name) Gets the value of a header by name.getHost()Get the Host header value.intgetIntegerHeaderValue(String name) Gets an integer header value by name.longgetLongHeaderValue(String name) Gets a long header value by name.intGets the number of headers in this HTTP packet.Get the Server header value.getStringHeaderValue(String name) Gets a string header value, stripping double quotes if present.getStringHeaderValue(String name, String startWidth, String endWidth) Gets a string header value, stripping the specified delimiters if present.Get the Transfer-Encoding header value.Gets the HTTP version of this packet.booleanChecks if the Connection header is set.booleanChecks if this HTTP packet has content.booleanChecks if a content input stream has been set.booleanChecks if the Content-Range or Range header is set.booleanChecks if the first line of the HTTP packet has been set.booleanChecks if a header with the specified name exists.booleanCheck if the Transfer-Encoding header is set.voidinit()Initializes the HTTP packet to empty state.booleanCheck if the content is chunked.booleanChecks if the Connection header is set to close.booleanChecks if the Connection header is set to keep-alive.booleanread(HTTPSocket httpSock) Reads and parses HTTP packet from a socket.protected booleanset(InputStream in) Parses HTTP packet data from an input stream including content.protected booleanset(InputStream in, boolean onlyHeaders) Parses HTTP packet data from an input stream.protected voidset(HTTPPacket httpPacket) Copies all data from another HTTP packet to this packet.protected booleanset(HTTPSocket httpSock) Parses HTTP packet data from an HTTP socket.voidsetCacheControl(int value) Set the Cache-Control header with a max-age value.voidsetCacheControl(String directive) Set the Cache-Control header.voidsetCacheControl(String directive, int value) Set the Cache-Control header with a directive and value.voidsetConnection(String value) Sets the Connection header.voidsetContent(byte[] data) Sets the content of this HTTP packet.voidsetContent(byte[] data, boolean updateWithContentLength) Sets the content of this HTTP packet.voidsetContent(String data) Sets the content of this HTTP packet from a string.voidsetContent(String data, boolean updateWithContentLength) Sets the content of this HTTP packet from a string.voidSets the content input stream.voidsetContentLanguage(String code) Sets the Content-Language header.voidsetContentLength(long len) Sets the Content-Length header.voidsetContentRange(long firstPos, long lastPos, long length) Sets the Content-Range header.voidsetContentType(String type) Sets the Content-Type header.voidSet the Date header.voidSets the value of a header from an integer.voidSets the value of a header from a long.voidSets the value of a header.voidsetHeader(HTTPHeader header) Sets the value of a header from an HTTP header object.voidSet the Host header.voidsetIntegerHeader(String name, int value) Sets an integer header value.voidsetLongHeader(String name, long value) Sets a long header value.voidSet the Server header.voidsetStringHeader(String name, String value) Sets a string header value, wrapping it with double quotes if not already wrapped.voidsetStringHeader(String name, String value, String startWidth, String endWidth) Sets a string header value, wrapping it with the specified delimiters if not already wrapped.voidsetTransferEncoding(String value) Set the Transfer-Encoding header.voidsetVersion(String ver) Sets the HTTP version for this packet.
Field Details
rootNode
/////////////////////////////////////////////
Constructor Details
SOAPResponse
public SOAPResponse()Creates an empty response carrying a fresh SOAP envelope body.SOAPResponse
Copies the connection state of an HTTP response, replacing its payload with an empty SOAP envelope.- Parameters:
httpRes- the response to copy the connection state from; its payload is discarded and replaced with an empty SOAP envelope
SOAPResponse
Adopts the envelope node of another SOAP response.- Parameters:
soapRes- the response whose envelope node is adopted, not copied, by this one
Method Details
setRootNode
Sets the SOAP body's root node.- Parameters:
node- the new root node
getRootNode
setEnvelopeNode
Set the SOAP envelope node.- Parameters:
node- the envelope node to set
getEnvelopeNode
Get the SOAP envelope node.- Returns:
- the envelope node, or null if not set
getBodyNode
getMethodResponseNode
getFaultNode
getFaultCodeNode
Get the SOAP fault code node.- Returns:
- the fault code node, or null if not found
getFaultStringNode
Get the SOAP fault string node.- Returns:
- the fault string node, or null if not found
getFaultActorNode
Get the SOAP fault actor node.- Returns:
- the fault actor node, or null if not found
getFaultDetailNode
Get the SOAP fault detail node.- Returns:
- the fault detail node, or null if not found
getFaultCode
Get the SOAP fault code string.- Returns:
- the fault code, or empty string if not found
getFaultString
Get the SOAP fault string.- Returns:
- the fault string, or empty string if not found
getFaultActor
Get the SOAP fault actor string.- Returns:
- the fault actor, or empty string if not found
setContent
Set the content from an XML node.- Parameters:
node- the XML node to set as content
print
public void print()Writes the response to the debug log, as text or as its root element.- Overrides:
printin classHTTPResponse