public class HttpExchangeConnection extends AbstractReceiverConnection implements EndpointAwareWebServiceConnection, FaultAwareWebServiceConnection
WebServiceConnection
that is based on the Java 6 HttpServer HttpExchange
.Modifier | Constructor and Description |
---|---|
protected |
HttpExchangeConnection(com.sun.net.httpserver.HttpExchange httpExchange)
Constructs a new exchange connection with the given
HttpExchange . |
Modifier and Type | Method and Description |
---|---|
void |
addResponseHeader(String name,
String value)
Adds a response header with the given name and value.
|
void |
endpointNotFound()
Called when an endpoint is not found.
|
String |
getErrorMessage()
Returns the error message.
|
com.sun.net.httpserver.HttpExchange |
getHttpExchange()
Returns the
HttpExchange for this connection. |
Iterator<String> |
getRequestHeaderNames()
Returns an iteration over all the header names this request contains.
|
Iterator<String> |
getRequestHeaders(String name)
Returns an iteration over all the string values of the specified header.
|
protected InputStream |
getRequestInputStream()
Returns the input stream to read the response from.
|
protected OutputStream |
getResponseOutputStream()
Returns the output stream to write the request to.
|
URI |
getUri()
Returns the URI for this connection.
|
boolean |
hasError()
Indicates whether this connection has an error.
|
boolean |
hasFault()
Indicates whether this connection received a fault.
|
void |
onClose()
Template method invoked from
AbstractWebServiceConnection.close() . |
protected void |
onSendAfterWrite(WebServiceMessage message)
Called after the given message has been written to the
TransportOutputStream . |
void |
setFault(boolean fault)
Deprecated.
|
void |
setFaultCode(QName faultCode)
Sets a specific fault code.
|
createTransportInputStream, createTransportOutputStream
close, onReceiveAfterRead, onReceiveBeforeRead, onSendBeforeWrite, receive, send
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, receive, send
protected HttpExchangeConnection(com.sun.net.httpserver.HttpExchange httpExchange)
HttpExchange
.public com.sun.net.httpserver.HttpExchange getHttpExchange()
HttpExchange
for this connection.public URI getUri() throws URISyntaxException
WebServiceConnection
getUri
in interface WebServiceConnection
URISyntaxException
public void endpointNotFound()
EndpointAwareWebServiceConnection
endpointNotFound
in interface EndpointAwareWebServiceConnection
public boolean hasError() throws IOException
WebServiceConnection
hasError
in interface WebServiceConnection
true
if this connection has an error; false
otherwise.IOException
public String getErrorMessage() throws IOException
WebServiceConnection
getErrorMessage
in interface WebServiceConnection
null
when no error is presentIOException
WebServiceConnection.hasError()
public Iterator<String> getRequestHeaderNames() throws IOException
HeadersAwareReceiverWebServiceConnection
Iterator
if
there are no headers.getRequestHeaderNames
in interface HeadersAwareReceiverWebServiceConnection
IOException
public Iterator<String> getRequestHeaders(String name) throws IOException
HeadersAwareReceiverWebServiceConnection
Iterator
if there are no headers of the specified name.getRequestHeaders
in interface HeadersAwareReceiverWebServiceConnection
IOException
protected InputStream getRequestInputStream() throws IOException
AbstractReceiverConnection
getRequestInputStream
in class AbstractReceiverConnection
IOException
public void addResponseHeader(String name, String value) throws IOException
HeadersAwareReceiverWebServiceConnection
addResponseHeader
in interface HeadersAwareReceiverWebServiceConnection
name
- the name of the headervalue
- the value of the headerIOException
protected OutputStream getResponseOutputStream() throws IOException
AbstractReceiverConnection
getResponseOutputStream
in class AbstractReceiverConnection
IOException
protected void onSendAfterWrite(WebServiceMessage message) throws IOException
AbstractWebServiceConnection
TransportOutputStream
. Called from AbstractWebServiceConnection.send(WebServiceMessage)
.
Default implementation does nothing.
onSendAfterWrite
in class AbstractWebServiceConnection
message
- the messageIOException
- when an I/O exception occurspublic void onClose() throws IOException
AbstractReceiverConnection
AbstractWebServiceConnection.close()
. Default implementation is empty.onClose
in class AbstractReceiverConnection
IOException
- if an I/O error occurs when closing this connectionpublic boolean hasFault() throws IOException
FaultAwareWebServiceConnection
Typically implemented by looking at an HTTP status code.
hasFault
in interface FaultAwareWebServiceConnection
true
if this connection received a fault; false
otherwise.IOException
- in case of I/O errors@Deprecated public void setFault(boolean fault) throws IOException
FaultAwareWebServiceConnection
Typically implemented by setting an HTTP status code.
setFault
in interface FaultAwareWebServiceConnection
fault
- true
if this will send a fault; false
otherwise.IOException
- in case of I/O errorspublic void setFaultCode(QName faultCode) throws IOException
FaultAwareWebServiceConnection
Typically implemented by setting an HTTP status code.
setFaultCode
in interface FaultAwareWebServiceConnection
faultCode
- the fault code to be set on the connection, or null
for no fault.IOException
- in case of I/O errors