/** * Return the Fault element from the SOAP message, if any. * * @param soapMessage the SOAP 1.1. Envelope being processed * @return the first Fault element found, or null */ protected Fault getFault(Envelope soapMessage) { if (soapMessage.getBody() != null) { List<XMLObject> faults = soapMessage.getBody().getUnknownXMLObjects(Fault.DEFAULT_ELEMENT_NAME); if (!faults.isEmpty()) { return (Fault) faults.get(0); } else { return null; } } else { return null; } }
/** {@inheritDoc} */ protected void doInvoke(MessageContext messageContext) throws MessageHandlerException { Envelope env = (Envelope) messageContext.getSubcontext(SOAP11Context.class).getEnvelope(); List<XMLObject> bodyChildren = env.getBody().getUnknownXMLObjects(); if (bodyChildren == null || bodyChildren.isEmpty()) { throw new MessageHandlerException("SOAP Envelope Body contained no children"); } else if (bodyChildren.size() > 1) { log.warn("SOAP Envelope Body contained more than one child. Returning the first as the message"); } messageContext.setMessage(env.getBody().getUnknownXMLObjects().get(0)); }
private String[] getPrincipalIdFromSamlEcpResponse(final Envelope envelope) { val objects = envelope.getBody().getUnknownXMLObjects(); if (objects.isEmpty()) { return ArrayUtils.EMPTY_STRING_ARRAY; } val object = objects.get(0); if (object instanceof Response) { return getPrincipalIdFromSamlResponse((Response) object); } if (object instanceof Fault) { return getPrincipalIdFromSamlEcpFault((Fault) object); } return ArrayUtils.EMPTY_STRING_ARRAY; }
/** * Get the HTTP response status code to return. * * @return the HTTP response status code */ protected int getHTTPResponseStatusCode() { Integer contextStatus = getMessageContext().getSubcontext(SOAP11Context.class, true).getHTTPResponseStatus(); if (contextStatus != null) { return contextStatus; } Envelope envelope = getSOAPEnvelope(); if (envelope != null && envelope.getBody() != null) { Body body = envelope.getBody(); List<XMLObject> faults = body.getUnknownXMLObjects(Fault.DEFAULT_ELEMENT_NAME); if (!faults.isEmpty()) { return HttpServletResponse.SC_INTERNAL_SERVER_ERROR; } } return HttpServletResponse.SC_OK; }
/** * Get the HTTP response status code to return. * * @return the HTTP response status code */ protected int getHTTPResponseStatusCode() { final Integer contextStatus = getMessageContext().getSubcontext(SOAP11Context.class, true).getHTTPResponseStatus(); if (contextStatus != null) { return contextStatus; } final Envelope envelope = getSOAPEnvelope(); if (envelope != null && envelope.getBody() != null) { final Body body = envelope.getBody(); final List<XMLObject> faults = body.getUnknownXMLObjects(Fault.DEFAULT_ELEMENT_NAME); if (!faults.isEmpty()) { return HttpServletResponse.SC_INTERNAL_SERVER_ERROR; } } return HttpServletResponse.SC_OK; }
/** * Builds the SOAP message to be encoded. * * @param payload body of the SOAP message */ protected void buildAndStoreSOAPMessage(@Nonnull final XMLObject payload) { Envelope envelope = getSOAPEnvelope(); if (envelope == null) { envelope = envBuilder.buildObject(); storeSOAPEnvelope(envelope); } Body body = envelope.getBody(); if (body == null) { body = bodyBuilder.buildObject(); envelope.setBody(body); } if (!body.getUnknownXMLObjects().isEmpty()) { log.warn("Existing SOAP Envelope Body already contained children"); } body.getUnknownXMLObjects().add(payload); }
/** * Builds the SOAP message to be encoded. * * @param payload body of the SOAP message */ protected void buildAndStoreSOAPMessage(@Nonnull final XMLObject payload) { Envelope envelope = getSOAPEnvelope(); if (envelope == null) { envelope = envBuilder.buildObject(); storeSOAPEnvelope(envelope); } Body body = envelope.getBody(); if (body == null) { body = bodyBuilder.buildObject(); envelope.setBody(body); } if (!body.getUnknownXMLObjects().isEmpty()) { log.warn("Existing SOAP Envelope Body already contained children"); } body.getUnknownXMLObjects().add(payload); }
/** * Builds the SOAP message to be encoded. * * @param payload body of the SOAP message */ protected void buildAndStoreSOAPMessage(@Nonnull final XMLObject payload) { Envelope envelope = getSOAPEnvelope(); if (envelope == null) { envelope = envBuilder.buildObject(); storeSOAPEnvelope(envelope); } Body body = envelope.getBody(); if (body == null) { body = bodyBuilder.buildObject(); envelope.setBody(body); } if (!body.getUnknownXMLObjects().isEmpty()) { log.warn("Existing SOAP Envelope Body already contained children"); } body.getUnknownXMLObjects().add(payload); }
final List<XMLObject> soapBodyChildren = soapMessage.getBody().getUnknownXMLObjects(); if (soapBodyChildren.size() < 1 || soapBodyChildren.size() > 1) { log.error("Unexpected number of children in the SOAP body, " + soapBodyChildren.size()
final List<XMLObject> soapBodyChildren = soapMessage.getBody().getUnknownXMLObjects(); if (soapBodyChildren.size() < 1 || soapBodyChildren.size() > 1) { log.error("Unexpected number of children in the SOAP body, " + soapBodyChildren.size()
context.getInboundMessageContext().getSubcontext(SOAP11Context.class, true).setEnvelope(response); if (response.getBody() != null) { final List<XMLObject> faults = response.getBody().getUnknownXMLObjects(Fault.DEFAULT_ELEMENT_NAME); if (faults.size() < 1) { throw new SOAPClientException("HTTP status code was 500 but SOAP response did not contain a Fault");