use of org.n52.shetland.w3c.soap.SoapChain in project arctic-sea by 52North.
the class SoapBinding method doPostOperation.
@Override
public void doPostOperation(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws HTTPException, IOException {
final SoapChain chain = new SoapChain(httpRequest, httpResponse);
try {
parseSoapRequest(chain);
checkForContext(chain, getRequestContext(httpRequest));
createSoapResponse(chain);
if (!chain.getSoapRequest().hasSoapFault()) {
// parseBodyRequest(chain);
createBodyResponse(chain);
}
writeResponse(chain);
} catch (OwsExceptionReport t) {
writeOwsExceptionReport(chain, t);
}
}
use of org.n52.shetland.w3c.soap.SoapChain in project arctic-sea by 52North.
the class SoapBinding method encodeSoapResponse.
private Object encodeSoapResponse(SoapChain chain) throws OwsExceptionReport, NoEncoderForKeyException {
EncoderKey key = new XmlEncoderKey(chain.getSoapResponse().getSoapNamespace(), chain.getSoapResponse().getClass());
Encoder<?, SoapResponse> encoder = getEncoder(key);
if (encoder != null) {
try {
return encoder.encode(chain.getSoapResponse());
} catch (OwsEncodingException ex) {
throw ex.getCause();
} catch (EncodingException ex) {
throw new NoApplicableCodeException().withMessage(ex.getMessage()).causedBy(ex);
}
} else {
NoEncoderForKeyException cause = new NoEncoderForKeyException(key);
throw new NoApplicableCodeException().withMessage(cause.getMessage()).causedBy(cause);
}
}
use of org.n52.shetland.w3c.soap.SoapChain in project arctic-sea by 52North.
the class SoapBinding method createBodyResponse.
private void createBodyResponse(SoapChain chain) throws OwsExceptionReport {
OwsServiceRequest req = chain.getSoapRequest().getSoapBodyContent();
chain.setBodyResponse(getServiceOperator(req).receiveRequest(req));
}
use of org.n52.shetland.w3c.soap.SoapChain in project arctic-sea by 52North.
the class SoapBinding method writeOwsExceptionReport.
private void writeOwsExceptionReport(SoapChain chain, OwsExceptionReport owse) throws HTTPException, IOException {
try {
String version = chain.hasBodyRequest() ? chain.getBodyRequest().getVersion() : null;
getEventBus().submit(new ExceptionEvent(owse));
chain.getSoapResponse().setException(owse.setVersion(version));
if (!chain.getSoapResponse().hasSoapVersion()) {
chain.getSoapResponse().setSoapVersion(SOAPConstants.SOAP_1_2_PROTOCOL);
}
if (!chain.getSoapResponse().hasSoapNamespace()) {
chain.getSoapResponse().setSoapNamespace(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE);
}
if (chain.getSoapResponse().hasException() && chain.getSoapResponse().getException().hasStatus()) {
chain.getHttpResponse().setStatus(chain.getSoapResponse().getException().getStatus().getCode());
}
checkSoapInjection(chain);
httpUtils.writeObject(chain.getHttpRequest(), chain.getHttpResponse(), checkMediaType(chain), encodeSoapResponse(chain), this);
} catch (OwsExceptionReport | NoEncoderForKeyException t) {
throw new HTTPException(HTTPStatus.INTERNAL_SERVER_ERROR, t);
}
}
use of org.n52.shetland.w3c.soap.SoapChain in project arctic-sea by 52North.
the class SoapBinding method writeResponse.
private void writeResponse(SoapChain chain) throws IOException, HTTPException {
MediaType contentType = chooseResponseContentType(chain.getBodyResponse(), HTTPHeaders.getAcceptHeader(chain.getHttpRequest()), getDefaultContentType());
// TODO allow other bindings to encode response as soap messages
if (contentType.isCompatible(getDefaultContentType())) {
checkSoapInjection(chain);
httpUtils.writeObject(chain.getHttpRequest(), chain.getHttpResponse(), checkMediaType(chain), chain, this);
} else {
httpUtils.writeObject(chain.getHttpRequest(), chain.getHttpResponse(), contentType, chain.getBodyResponse(), this);
}
}
Aggregations