use of uk.gov.ida.hub.samlsoapproxy.soap.SoapResponse in project verify-hub by alphagov.
the class HealthCheckSoapRequestClient method makeSoapRequestForHealthCheck.
public HealthCheckResponse makeSoapRequestForHealthCheck(Element requestElement, URI uri) {
LOG.info(MessageFormat.format("Making SOAP request to: {0}", uri));
SoapResponse response;
try {
response = makePost(uri, requestElement);
} catch (ProcessingException e) {
throw ApplicationException.createUnauditedException(ExceptionType.NETWORK_ERROR, UUID.randomUUID(), e);
} catch (SOAPRequestError e) {
throw ApplicationException.createUnauditedException(ExceptionType.REMOTE_SERVER_ERROR, UUID.randomUUID(), e);
}
return new HealthCheckResponse(response.getBody(), Optional.fromNullable(response.getHeaders().getFirst(MSA_VERSION_HTTP_HEADER)));
}
use of uk.gov.ida.hub.samlsoapproxy.soap.SoapResponse in project verify-hub by alphagov.
the class SoapRequestClient method makePost.
/**
* Wrap the supplied element in a SOAP wrapper and post to the specified end-point
*
* @return Response from the remote server
* @throws SOAPRequestError if the remote server returns a non-200 status code
* @throws ResponseProcessingException in case processing of a received HTTP response fails (e.g. in a filter
* or during conversion of the response entity data to an instance
* of a particular Java type).
* @throws ProcessingException in case the request processing or subsequent I/O operation fails.
*/
protected SoapResponse makePost(URI uri, Element requestElement) throws SOAPRequestError {
LOG.info(format("Making SOAP request to: {0}", uri));
Document requestDocument = soapMessageManager.wrapWithSoapEnvelope(requestElement);
WebTarget target = client.target(uri);
final Invocation.Builder request = target.request();
final Response response = request.post(Entity.entity(requestDocument, MediaType.TEXT_XML_TYPE));
try {
if (response.getStatus() != 200) {
LOG.warn(format("Unexpected status code ({0}) when contacting ({1}))", response.getStatus(), uri));
// let the calling code handle this issue appropriately
throw new SOAPRequestError(response);
} else {
try {
return giveMeMySoap(response);
} catch (BadRequestException e) {
LOG.warn(format("Couldn't parse SOAP response when contacting ({0}))", uri), e);
throw new SOAPRequestError(response, e);
}
}
} finally {
// (e.g. the response body is never read from).
try {
response.close();
} catch (ProcessingException f) {
LOG.warn("Problem closing Jersey connection.", f);
}
}
}
use of uk.gov.ida.hub.samlsoapproxy.soap.SoapResponse in project verify-hub by alphagov.
the class SoapRequestClient method giveMeMySoap.
private SoapResponse giveMeMySoap(Response response) {
Document document = response.readEntity(Document.class);
Element unwrappedSoap = soapMessageManager.unwrapSoapMessage(document);
return new SoapResponse(unwrappedSoap, response.getStringHeaders());
}
Aggregations