Spring Web Services Framework

org.springframework.ws.transport.http
Class HttpExchangeConnection

java.lang.Object
  extended by org.springframework.ws.transport.AbstractWebServiceConnection
      extended by org.springframework.ws.transport.AbstractReceiverConnection
          extended by org.springframework.ws.transport.http.HttpExchangeConnection
All Implemented Interfaces:
EndpointAwareWebServiceConnection, FaultAwareWebServiceConnection, WebServiceConnection

public class HttpExchangeConnection
extends AbstractReceiverConnection
implements EndpointAwareWebServiceConnection, FaultAwareWebServiceConnection

Implementation of WebServiceConnection that is based on the Java 6 HttpServer HttpExchange.

Since:
1.5.0
Author:
Arjen Poutsma

Constructor Summary
protected HttpExchangeConnection(HttpExchange httpExchange)
          Constructs a new exchange connection with the given HttpExchange.
 
Method Summary
protected  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.
 HttpExchange getHttpExchange()
          Returns the HttpExchange for this connection.
protected  Iterator<String> getRequestHeaderNames()
          Returns an iteration over all the header names this request contains.
protected  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)
          Sets whether this connection will send a fault.
 
Methods inherited from class org.springframework.ws.transport.AbstractReceiverConnection
createTransportInputStream, createTransportOutputStream
 
Methods inherited from class org.springframework.ws.transport.AbstractWebServiceConnection
close, onReceiveAfterRead, onReceiveBeforeRead, onSendBeforeWrite, receive, send
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.ws.transport.WebServiceConnection
close, receive, send
 

Constructor Detail

HttpExchangeConnection

protected HttpExchangeConnection(HttpExchange httpExchange)
Constructs a new exchange connection with the given HttpExchange.

Method Detail

getHttpExchange

public HttpExchange getHttpExchange()
Returns the HttpExchange for this connection.


getUri

public URI getUri()
           throws URISyntaxException
Description copied from interface: WebServiceConnection
Returns the URI for this connection.

Specified by:
getUri in interface WebServiceConnection
Throws:
URISyntaxException

endpointNotFound

public void endpointNotFound()
Description copied from interface: EndpointAwareWebServiceConnection
Called when an endpoint is not found.

Specified by:
endpointNotFound in interface EndpointAwareWebServiceConnection

hasError

public boolean hasError()
                 throws IOException
Description copied from interface: WebServiceConnection
Indicates whether this connection has an error. Typically, error detection is done by inspecting connection error codes, etc.

Specified by:
hasError in interface WebServiceConnection
Returns:
true if this connection has an error; false otherwise.
Throws:
IOException

getErrorMessage

public String getErrorMessage()
                       throws IOException
Description copied from interface: WebServiceConnection
Returns the error message.

Specified by:
getErrorMessage in interface WebServiceConnection
Returns:
the connection error message, if any; returns null when no error is present
Throws:
IOException
See Also:
WebServiceConnection.hasError()

getRequestHeaderNames

protected Iterator<String> getRequestHeaderNames()
                                          throws IOException
Description copied from class: AbstractReceiverConnection
Returns an iteration over all the header names this request contains. Returns an empty Iterator if there are no headers.

Specified by:
getRequestHeaderNames in class AbstractReceiverConnection
Throws:
IOException

getRequestHeaders

protected Iterator<String> getRequestHeaders(String name)
                                      throws IOException
Description copied from class: AbstractReceiverConnection
Returns an iteration over all the string values of the specified header. Returns an empty Iterator if there are no headers of the specified name.

Specified by:
getRequestHeaders in class AbstractReceiverConnection
Throws:
IOException

getRequestInputStream

protected InputStream getRequestInputStream()
                                     throws IOException
Description copied from class: AbstractReceiverConnection
Returns the input stream to read the response from.

Specified by:
getRequestInputStream in class AbstractReceiverConnection
Throws:
IOException

addResponseHeader

protected void addResponseHeader(String name,
                                 String value)
                          throws IOException
Description copied from class: AbstractReceiverConnection
Adds a response header with the given name and value. This method can be called multiple times, to allow for headers with multiple values.

Specified by:
addResponseHeader in class AbstractReceiverConnection
Parameters:
name - the name of the header
value - the value of the header
Throws:
IOException

getResponseOutputStream

protected OutputStream getResponseOutputStream()
                                        throws IOException
Description copied from class: AbstractReceiverConnection
Returns the output stream to write the request to.

Specified by:
getResponseOutputStream in class AbstractReceiverConnection
Throws:
IOException

onSendAfterWrite

protected void onSendAfterWrite(WebServiceMessage message)
                         throws IOException
Description copied from class: AbstractWebServiceConnection
Called after the given message has been written to the TransportOutputStream. Called from AbstractWebServiceConnection.send(WebServiceMessage).

Default implementation does nothing.

Overrides:
onSendAfterWrite in class AbstractWebServiceConnection
Parameters:
message - the message
Throws:
IOException - when an I/O exception occurs

onClose

public void onClose()
             throws IOException
Description copied from class: AbstractReceiverConnection
Template method invoked from AbstractWebServiceConnection.close(). Default implementation is empty.

Overrides:
onClose in class AbstractReceiverConnection
Throws:
IOException - if an I/O error occurs when closing this connection

hasFault

public boolean hasFault()
                 throws IOException
Description copied from interface: FaultAwareWebServiceConnection
Indicates whether this connection received a fault.

Typically implemented by looking at an HTTP status code.

Specified by:
hasFault in interface FaultAwareWebServiceConnection
Returns:
true if this connection received a fault; false otherwise.
Throws:
IOException - in case of I/O errors

setFault

public void setFault(boolean fault)
              throws IOException
Description copied from interface: FaultAwareWebServiceConnection
Sets whether this connection will send a fault.

Typically implemented by setting an HTTP status code.

Specified by:
setFault in interface FaultAwareWebServiceConnection
Parameters:
fault - true if this will send a fault; false otherwise.
Throws:
IOException - in case of I/O errors

Spring Web Services Framework

Copyright © 2005-2013 The Spring Web Services Framework. All Rights Reserved.