Class HttpServletConnection
java.lang.Object
org.springframework.ws.transport.AbstractWebServiceConnection
org.springframework.ws.transport.AbstractReceiverConnection
org.springframework.ws.transport.http.HttpServletConnection
- All Implemented Interfaces:
AutoCloseable
,EndpointAwareWebServiceConnection
,FaultAwareWebServiceConnection
,HeadersAwareReceiverWebServiceConnection
,WebServiceConnection
public class HttpServletConnection
extends AbstractReceiverConnection
implements EndpointAwareWebServiceConnection, FaultAwareWebServiceConnection
Implementation of
WebServiceConnection
that is based on the Servlet API.- Since:
- 1.0.0
- Author:
- Arjen Poutsma, Greg Turnquist
-
Constructor Summary
ModifierConstructorDescriptionprotected
HttpServletConnection
(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) Constructs a new servlet connection with the givenHttpServletRequest
andHttpServletResponse
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addResponseHeader
(String name, String value) Adds a response header with the given name and value.void
Called when an endpoint is not found.Returns the error message.jakarta.servlet.http.HttpServletRequest
Returns theHttpServletRequest
for this connection.jakarta.servlet.http.HttpServletResponse
Returns theHttpServletResponse
for this connection.Returns an iteration over all the header names this request contains.getRequestHeaders
(String name) Returns an iteration over all the string values of the specified header.protected InputStream
Returns the input stream to read the response from.protected OutputStream
Returns the output stream to write the request to.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 fromAbstractWebServiceConnection.close()
.protected void
onSendAfterWrite
(WebServiceMessage message) Called after the given message has been written to theTransportOutputStream
.void
setFault
(boolean fault) Deprecated.void
setFaultCode
(QName faultCode) Sets a specific fault code.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 Details
-
HttpServletConnection
protected HttpServletConnection(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) Constructs a new servlet connection with the givenHttpServletRequest
andHttpServletResponse
.
-
-
Method Details
-
getHttpServletRequest
public jakarta.servlet.http.HttpServletRequest getHttpServletRequest()Returns theHttpServletRequest
for this connection. -
getHttpServletResponse
public jakarta.servlet.http.HttpServletResponse getHttpServletResponse()Returns theHttpServletResponse
for this connection. -
endpointNotFound
public void endpointNotFound()Description copied from interface:EndpointAwareWebServiceConnection
Called when an endpoint is not found.- Specified by:
endpointNotFound
in interfaceEndpointAwareWebServiceConnection
-
hasError
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 interfaceWebServiceConnection
- Returns:
true
if this connection has an error;false
otherwise.- Throws:
IOException
-
getErrorMessage
Description copied from interface:WebServiceConnection
Returns the error message.- Specified by:
getErrorMessage
in interfaceWebServiceConnection
- Returns:
- the connection error message, if any; returns
null
when no error is present - Throws:
IOException
- See Also:
-
getUri
Description copied from interface:WebServiceConnection
Returns the URI for this connection.- Specified by:
getUri
in interfaceWebServiceConnection
- Throws:
URISyntaxException
-
getRequestHeaderNames
Description copied from interface:HeadersAwareReceiverWebServiceConnection
Returns an iteration over all the header names this request contains. Returns an emptyIterator
if there are no headers.- Specified by:
getRequestHeaderNames
in interfaceHeadersAwareReceiverWebServiceConnection
- Throws:
IOException
-
getRequestHeaders
Description copied from interface:HeadersAwareReceiverWebServiceConnection
Returns an iteration over all the string values of the specified header. Returns an emptyIterator
if there are no headers of the specified name.- Specified by:
getRequestHeaders
in interfaceHeadersAwareReceiverWebServiceConnection
- Throws:
IOException
-
getRequestInputStream
Description copied from class:AbstractReceiverConnection
Returns the input stream to read the response from.- Specified by:
getRequestInputStream
in classAbstractReceiverConnection
- Throws:
IOException
-
addResponseHeader
Description copied from interface:HeadersAwareReceiverWebServiceConnection
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 interfaceHeadersAwareReceiverWebServiceConnection
- Parameters:
name
- the name of the headervalue
- the value of the header- Throws:
IOException
-
getResponseOutputStream
Description copied from class:AbstractReceiverConnection
Returns the output stream to write the request to.- Specified by:
getResponseOutputStream
in classAbstractReceiverConnection
- Throws:
IOException
-
onSendAfterWrite
Description copied from class:AbstractWebServiceConnection
Called after the given message has been written to theTransportOutputStream
. Called fromAbstractWebServiceConnection.send(WebServiceMessage)
.Default implementation does nothing.
- Overrides:
onSendAfterWrite
in classAbstractWebServiceConnection
- Parameters:
message
- the message- Throws:
IOException
- when an I/O exception occurs
-
onClose
Description copied from class:AbstractReceiverConnection
Template method invoked fromAbstractWebServiceConnection.close()
. Default implementation is empty.- Overrides:
onClose
in classAbstractReceiverConnection
- Throws:
IOException
- if an I/O error occurs when closing this connection
-
hasFault
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 interfaceFaultAwareWebServiceConnection
- Returns:
true
if this connection received a fault;false
otherwise.- Throws:
IOException
- in case of I/O errors
-
setFault
Deprecated.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 interfaceFaultAwareWebServiceConnection
- Parameters:
fault
-true
if this will send a fault;false
otherwise.- Throws:
IOException
- in case of I/O errors
-
setFaultCode
Description copied from interface:FaultAwareWebServiceConnection
Sets a specific fault code.Typically implemented by setting an HTTP status code.
- Specified by:
setFaultCode
in interfaceFaultAwareWebServiceConnection
- Parameters:
faultCode
- the fault code to be set on the connection, ornull
for no fault.- Throws:
IOException
- in case of I/O errors
-