Package org.opensaml.soap.client.http
Class HttpSOAPClient
java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
org.opensaml.soap.client.http.HttpSOAPClient
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,SOAPClient
@ThreadSafe
public class HttpSOAPClient
extends AbstractInitializableComponent
implements SOAPClient
SOAP client that uses HTTP as the underlying transport and POST as the binding.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensaml.soap.client.SOAPClient
SOAPClient.SOAPRequestParameters -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.http.client.HttpClientHTTP client used to send requests and receive responses.private final org.slf4j.LoggerClass logger.private ParserPoolPool of XML parsers used to parser incoming responses.private Function<MessageContext,SOAP11Context> Strategy used to look up theSOAP11Contextassociated with the outbound message context.private Function<MessageContext,SOAPClientContext> Strategy used to look up theSOAPClientContextassociated with the outbound message context. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.http.client.methods.HttpPostcreatePostMethod(String endpoint, HttpSOAPRequestParameters requestParams, Envelope message) Create the post method used to send the SOAP request.protected org.apache.http.HttpEntitycreateRequestEntity(Envelope message, Charset charset) Create the request entity that makes up the POST message body.protected voidprotected voidevaluateSecurityPolicy(SOAPClientContext messageContext) Evaluates the security policy associated with the given message context.Get the strategy used to look up theSOAP11Contextassociated with the outbound message context.Get the strategy used to look up theSOAPClientContextassociated with the outbound message context.protected voidprocessFaultResponse(org.apache.http.HttpResponse httpResponse, InOutOperationContext context) Process a SOAP fault, as determined by an HTTP 500 status code, response.protected voidprocessSuccessfulResponse(org.apache.http.HttpResponse httpResponse, InOutOperationContext context) Process a successful, as determined by an HTTP 200 status code, response.voidsend(String endpoint, InOutOperationContext context) Sends a message and waits for a response.voidsetHttpClient(org.apache.http.client.HttpClient client) Set the client used to make outbound HTTP requests.voidsetParserPool(ParserPool parser) Set the pool of XML parsers used to parse incoming responses.voidSet the strategy used to look up theSOAP11Contextassociated with the outbound message context.voidSet the strategy used to look up theSOAPClientContextassociated with the outbound message context.protected EnvelopeunmarshallResponse(InputStream responseStream) Unmarshall the incoming response from a POST request.Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
httpClient
HTTP client used to send requests and receive responses. -
parserPool
Pool of XML parsers used to parser incoming responses. -
soapClientContextLookupStrategy
Strategy used to look up theSOAPClientContextassociated with the outbound message context. -
soap11ContextLookupStrategy
Strategy used to look up theSOAP11Contextassociated with the outbound message context.
-
-
Constructor Details
-
HttpSOAPClient
public HttpSOAPClient()Constructor.
-
-
Method Details
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
setHttpClient
public void setHttpClient(@Nonnull org.apache.http.client.HttpClient client) Set the client used to make outbound HTTP requests.This client SHOULD employ a thread-safe
HttpClientand may be shared with other objects.- Parameters:
client- client object
-
setParserPool
Set the pool of XML parsers used to parse incoming responses.- Parameters:
parser- parser pool
-
getSOAPClientContextLookupStrategy
Get the strategy used to look up theSOAPClientContextassociated with the outbound message context.- Returns:
- strategy used to look up the
SOAPClientContextassociated with the outbound message context
-
setSOAPClientContextLookupStrategy
public void setSOAPClientContextLookupStrategy(@Nonnull Function<MessageContext, SOAPClientContext> strategy) Set the strategy used to look up theSOAPClientContextassociated with the outbound message context.- Parameters:
strategy- strategy used to look up theSOAPClientContextassociated with the outbound message context
-
getSOAP11ContextLookupStrategy
Get the strategy used to look up theSOAP11Contextassociated with the outbound message context.- Returns:
- strategy used to look up the
SOAP11Contextassociated with the outbound message context
-
setSOAP11ContextLookupStrategy
public void setSOAP11ContextLookupStrategy(@Nonnull Function<MessageContext, SOAP11Context> strategy) Set the strategy used to look up theSOAP11Contextassociated with the outbound message context.- Parameters:
strategy- strategy used to look up theSOAP11Contextassociated with the outbound message context
-
send
public void send(@Nonnull @NotEmpty String endpoint, @Nonnull InOutOperationContext context) throws SOAPException, SecurityException Sends a message and waits for a response.- Specified by:
sendin interfaceSOAPClient- Parameters:
endpoint- the endpoint to which to send the messagecontext- the operation context containing the outbound SOAP message- Throws:
SOAPException- thrown if there is a problem sending the message or receiving the response or if the response is a SOAP faultSecurityException- thrown if the response does not meet any security policy associated with the message context
-
createPostMethod
protected org.apache.http.client.methods.HttpPost createPostMethod(@Nonnull @NotEmpty String endpoint, @Nullable HttpSOAPRequestParameters requestParams, @Nonnull Envelope message) throws SOAPClientException Create the post method used to send the SOAP request.- Parameters:
endpoint- endpoint to which the message is sentrequestParams- HTTP request parametersmessage- message to be sent- Returns:
- the post method to be used to send this message
- Throws:
SOAPClientException- thrown if the message could not be marshalled
-
createRequestEntity
protected org.apache.http.HttpEntity createRequestEntity(@Nonnull Envelope message, @Nullable Charset charset) throws SOAPClientException Create the request entity that makes up the POST message body.- Parameters:
message- message to be sentcharset- character set used for the message- Returns:
- request entity that makes up the POST message body
- Throws:
SOAPClientException- thrown if the message could not be marshalled
-
processSuccessfulResponse
protected void processSuccessfulResponse(@Nonnull org.apache.http.HttpResponse httpResponse, @Nonnull InOutOperationContext context) throws SOAPClientException Process a successful, as determined by an HTTP 200 status code, response.- Parameters:
httpResponse- the HTTP responsecontext- current operation context- Throws:
SOAPClientException- thrown if there is a problem reading the response from theHttpPost
-
processFaultResponse
protected void processFaultResponse(@Nonnull org.apache.http.HttpResponse httpResponse, @Nonnull InOutOperationContext context) throws SOAPClientException, SOAPFaultException Process a SOAP fault, as determined by an HTTP 500 status code, response.- Parameters:
httpResponse- the HTTP responsecontext- current operation context- Throws:
SOAPClientException- thrown if the response can not be read from theHttpPostSOAPFaultException- an exception containing the SOAP fault
-
unmarshallResponse
protected Envelope unmarshallResponse(@Nonnull InputStream responseStream) throws SOAPClientException Unmarshall the incoming response from a POST request.- Parameters:
responseStream- input stream bearing the response- Returns:
- the response
- Throws:
SOAPClientException- thrown if the incoming response can not be unmarshalled into anEnvelope
-
evaluateSecurityPolicy
Evaluates the security policy associated with the given message context. If no policy resolver is registered or no policy is located during the resolution process then no policy is evaluated. Note that neither the inbound or outbound message transport is available.- Parameters:
messageContext- current message context- Throws:
SOAPClientException- thrown if there is a problem resolving or evaluating a security policy
-