&& msg.getSOAPPart().getEnvelope().getBody().hasFault()) { return null;
/** Returns <code>true</code> if the body has a fault, <code>false</code> otherwise. */ @Override public boolean hasFault(SOAPBody body) { return body.hasFault(); }
@Override public boolean hasFault(SOAPBody body) { return body.hasFault(); }
@Override public boolean hasFault(SOAPBody body) { return body.hasFault(); }
@Override public boolean hasFault() { return getSaajBody().hasFault(); }
@Override public boolean hasFault() { return getSaajBody().hasFault(); }
@Override public boolean hasFault() { return getSaajBody().hasFault(); }
public boolean hasFault(MessageContext msgContext) { boolean hasFault = false; SOAPMessage msg = ((SOAPMessageContext)msgContext).getMessage(); assert msg != null; try { hasFault = msg.getSOAPBody().hasFault(); } catch (SOAPException se) { LOG.log(Level.SEVERE, "SOAP_UNMARSHALLING_FAILURE_MSG", se); throw new ProtocolException(se); } return hasFault; }
final SOAPMessage msg = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL) .createMessage(new MimeHeaders(), new ByteArrayInputStream(yourSoapMessageWithFault.getBytes())); if (msg != null) { SOAPEnvelope env = msg.getSOAPPart().getEnvelope(); SOAPBody body = env.getBody(); if (body != null && body.hasFault()) { final SOAPFault fault = body.getFault(); final DetailEntry entry = (DetailEntry)fault.getDetail().getDetailEntries().next(); //now UNMarshall this entry to your custom exception class.
public Message parseMessage() { Message output = null; try { String relatesTo = getElementValue(HEADER_RELATESTO); String action = getElementValue(HEADER_ACTION); if (relatesTo != null && !relatesTo.isEmpty() && action != null && action.endsWith("Response")) { if (soapMessage.getSOAPBody().hasFault()) output = parseError(); else output = parseResult(); } else { output = parseCall(); } if (action != null && !action.isEmpty()) output.setAction(action.substring(1)); if (!soapMessage.getSOAPBody().hasFault()) output.setPayload(soapMessage.getSOAPBody().extractContentAsDocument()); } catch (SOAPException e) { logger.warn("parseMessage() failed", e); } return output; }
public void callWebService() throws SOAPException, IOException { SOAPMessage request = createEchoRequest(); SOAPConnection connection = connectionFactory.createConnection(); SOAPMessage response = connection.call(request, url); if (!response.getSOAPBody().hasFault()) { writeEchoResponse(response); } else { SOAPFault fault = response.getSOAPBody().getFault(); System.err.println("Received SOAP Fault"); System.err.println("SOAP Fault Code :" + fault.getFaultCode()); System.err.println("SOAP Fault String :" + fault.getFaultString()); } }
SOAPBody body = f.getSOAPBody(); if (body.hasFault()) { SOAPFault newFault = body.getFault(); if (newFault != null) {
if (response.getSOAPBody().hasFault()) { responseNode = response.getSOAPBody().getFault();
public Element send(Element request, URI endpointURL) throws TransportException { if (log.isDebugEnabled()) { String requestMessage = XMLUtils.convertNodeToXMLString(request); log.debug("Request message: %s\n%s" + endpointURL + ":" + requestMessage); } Element response = null; try { SOAPMessage message = this.createSOAPMessage(request); //Make the SAAJ Call now SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); SOAPMessage soapResponse = connection.call(message, endpointURL.toURL()); SOAPBody soapBody = soapResponse.getSOAPBody(); boolean hasFault = soapBody.hasFault(); if (hasFault) { SOAPFault soapFault = soapBody.getFault(); String faultStr = soapFault.getFaultCode() + "::" + soapFault.getFaultString(); throw new RegistryException(faultStr); } response = getFirstChildElement(soapBody); } catch (Exception ex) { log.error("Exception::" + ex.getMessage(), ex); throw new TransportException(ex); } if (log.isDebugEnabled()) { String responseMessage = XMLUtils.convertNodeToXMLString(response); log.debug("Response message: %s" + responseMessage); } return response; }
public boolean handleMessage(SOAPMessageContext smc) { /* * Apparently handleFault does not always receive SOAPfaults as it should, so we try to * intercept them here */ SOAPMessage f = smc.getMessage(); try { //SOAPBody body = f.getSOAPBody(); SOAPBody body = f.getSOAPPart().getEnvelope().getBody(); if (body.hasFault()) { if (body.getFault() == null) { System.err.println("No SOAP FAULT found..."); return true; } return handleFault(smc); } } catch (SOAPException se) { System.err.println("Exception while handling fault"); se.printStackTrace(); } /* end fault-handling addition */ Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty.booleanValue()) { logToSystemOut(smc); return handleRequest(smc); } else { logToSystemOut(smc); return handleResponse(smc); } }
Assert.assertFalse(responded.getSOAPBody().hasFault()); final SOAPBodyElement result = this.getSOAPBodyElement(responded);
&& msg.getSOAPPart().getEnvelope().getBody().hasFault()) { return null;
@Override protected void done() { if (!isCancelled()) { try { SOAPMessage msg = get(); if (msg.getSOAPBody().hasFault()) { op.setResponseDocument(msg.getSOAPBody().getFault().getOwnerDocument()); } else { op.setResponseDocument(msg.getSOAPBody().extractContentAsDocument()); } } catch (CancellationException cancelled) { // it was aborted, nothing to do since the // abort method sets the state } catch (ExecutionException e) { //something went awry op.fail(e.getCause()); } catch (Exception e) { //something went awry op.fail(e); } } } }
/** * Executes SOAP message * * @param endpointUrl SOAP endpoint * @param message SOAP request * @return SOAP response message * @throws SOAPException in case of a SOAP issue * @throws IOException in case of an IO issue */ public SOAPMessage execute(String endpointUrl, SOAPMessage message) throws SOAPException, IOException { SOAPConnection conn = null; try { conn = SOAPConnectionFactory.newInstance().createConnection(); SOAPMessage response = conn.call(message, endpointUrl); SOAPBody body = response.getSOAPBody(); if (body.hasFault()) throw new SOAPException(body.getFault().getFaultString()); return response; } finally { if (conn != null) conn.close(); } }
public boolean handleFault(SOAPMessageContext ctx) { super.handleFault(ctx); try { Boolean outbound = (Boolean) ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { SOAPEnvelope env = ctx.getMessage().getSOAPPart().getEnvelope(); assertTrue("expected SOAPFault in SAAJ model", env.getBody().hasFault()); } } catch (Exception e) { e.printStackTrace(); fail(e.toString()); } return true; } };