public void handleMessage(SoapMessage message) throws Fault { BindingOperationInfo bop = message.getExchange().getBindingOperationInfo(); if (bop == null) { return; if (bop.isUnwrapped()) { bop = bop.getWrappedOperation(); BindingMessageInfo bmi = client ? bop.getOutput() : bop.getInput(); String partName = mpi.getConcreteName().getLocalPart(); throw new Fault(e); o = IOUtils.readBytesFromStream(dh.getInputStream()); } catch (IOException e) { throw new Fault(e); o = ImageIO.read(dh.getInputStream()); } catch (IOException e) { throw new Fault(e); o = new StreamSource(dh.getInputStream()); } catch (IOException e) { throw new Fault(e);
Throwable thr = f.getCause(); SOAPFaultException sf = null; if (thr instanceof SOAPFaultException) { f.setLang(convertedLang); Throwable cause = f.getCause(); WebFault fault = null; if (cause != null) { throw new Fault(new org.apache.cxf.common.i18n.Message("INVOCATION_TARGET_EXC", BUNDLE), e); } catch (IllegalAccessException | IllegalArgumentException e) { throw new Fault(new org.apache.cxf.common.i18n.Message("COULD_NOT_INVOKE", BUNDLE), e); OperationInfo op = message.getExchange().getBindingOperationInfo().getOperationInfo(); QName faultName = getFaultName(fault, cause.getClass(), op); MessagePartInfo part = getFaultMessagePart(faultName, op); if (f.hasDetails()) { writer.write(faultInfo, part, new W3CDOMStreamWriter(f.getDetail())); } else { writer.write(faultInfo, part, new W3CDOMStreamWriter(f.getOrCreateDetail())); if (!f.getDetail().hasChildNodes()) { f.setDetail(null); f.setMessage(ex.getMessage()); } catch (Exception nex) { if (nex instanceof Fault) {
private String getMessageValueIfThere(Fault exceptionFault) { if(exceptionFault.getMessage() != null) { return exceptionFault.getMessage(); } return UNKNOWN_ERROR; }
public void handleMessage(Message message) { BindingOperationInfo bop = message.getExchange().getBindingOperationInfo(); if (bop != null && bop.isUnwrapped()) { XMLStreamWriter xmlWriter = message.getContent(XMLStreamWriter.class); messageInfo = bop.getWrappedOperation().getOperationInfo().getInput(); } else { messageInfo = bop.getWrappedOperation().getOperationInfo().getOutput(); Service service = message.getExchange().getService(); if (service.getDataBinding().getDeclaredNamespaceMappings() != null) { pfx = service.getDataBinding().getDeclaredNamespaceMappings().get(name.getNamespaceURI()); pfx = StaxUtils.getUniquePrefix(xmlWriter, name.getNamespaceURI(), false); xmlWriter.setPrefix(pfx, name.getNamespaceURI()); xmlWriter.writeStartElement(pfx, name.getLocalPart(), name.getNamespaceURI()); if (StringUtils.isEmpty(pfx)) { throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_WRITE_EXC", BUNDLE), e); message.getInterceptorChain().add(ending);
private void writeMessage(Message message, QName name, boolean executeBare) { XMLStreamWriter xmlWriter = message.getContent(XMLStreamWriter.class); try { String pfx = name.getPrefix(); if (StringUtils.isEmpty(pfx)) { pfx = "ns1"; } StaxUtils.writeStartElement(xmlWriter, pfx, name.getLocalPart(), name.getNamespaceURI()); if (executeBare) { new BareOutInterceptor().handleMessage(message); } xmlWriter.writeEndElement(); } catch (XMLStreamException e) { throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_WRITE_EXC", BUNDLE, e)); } } }
return; Endpoint ep = message.getExchange().getEndpoint(); XMLStreamReader xsr = message.getContent(XMLStreamReader.class); if (xsr == null) { return; if (!StaxUtils.toNextElement(reader)) { throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OPERATION_ELEMENT", LOG)); Exchange ex = message.getExchange(); QName startQName = reader.getName(); if (startQName.getLocalPart().equals(XMLFault.XML_FAULT_ROOT)) { message.getInterceptorChain().abort(); if (ep.getInFaultObserver() != null) { ep.getInFaultObserver().onMessage(message); return; BindingMessageInfo bmi = isRequestor ? boi.getOutput() : boi.getInput(); xsr.nextTag(); } catch (XMLStreamException xse) { throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_READ_EXC", LOG));
private void createFaultDetail(Document faultData, FaultInfo faultInfo, Fault faultEx) { MessagePartInfo partInfo = faultInfo.getMessageParts().get(0); QName partInfoName = partInfo.getElementQName(); Document faultDoc = DOMUtils.getEmptyDocument(); Element faultElement = faultDoc.createElement("detail"); Element partElement = faultDoc.createElementNS(partInfoName.getNamespaceURI(), partInfoName.getLocalPart()); Element faultDataElement = (Element) faultData.getFirstChild(); Node node = faultDataElement.getFirstChild(); while (node != null) { Node importedFaultData = faultDoc.importNode(node, true); partElement.appendChild(importedFaultData); node = node.getNextSibling(); } faultElement.appendChild(partElement); faultEx.setDetail(faultElement); }
void throwFault(String message) { Fault fault = new Fault(new Exception(message)); fault.setFaultCode(new QName("Client")); fault.setStatusCode(ERROR_CODE); throw fault; } }
String partName = mpi.getConcreteName().getLocalPart(); String ct = (String) mpi.getProperty(Message.CONTENT_TYPE); throw new Fault(new org.apache.cxf.common.i18n.Message("ATTACHMENT_NOT_SUPPORTED", LOG, o.getClass()));
public void handleMessage(Message message) throws Fault { BindingOperationInfo bop = message.getExchange().getBindingOperationInfo(); if (bop != null && !bindingName.equals(bop.getBinding().getName())) { return; } else if (DataSource.class.isAssignableFrom(type)) { deser.initializeAttachments(); } catch (IOException ex) { throw new Fault(ex); message.setAttachments(msg.getAttachments()); out.close(); } catch (IOException e) { throw new Fault(e); message.setContent(OutputStream.class, out); XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out); message.setContent(XMLStreamWriter.class, writer); if (!(ds instanceof DOMSource)) { try { ds = new DOMSource(StaxUtils.read(ds)); } catch (XMLStreamException e) { throw new Fault(e);
public void handleMessage(Message message) throws Fault { Exchange ex = message.getExchange(); BindingOperationInfo boi = ex.getBindingOperationInfo(); if (Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE)) || boi == null) { return; Method method = ex.get(Method.class); if (boi.isUnwrappedCapable()) { BindingOperationInfo boi2 = boi.getUnwrappedOperation(); OperationInfo op = boi2.getOperationInfo(); BindingMessageInfo bmi; MessageInfo wrappedMessageInfo = message.get(MessageInfo.class); MessageInfo messageInfo; if (wrappedMessageInfo == boi.getOperationInfo().getInput()) { message.put(MessageInfo.class, messageInfo); message.put(BindingMessageInfo.class, bmi); ex.put(BindingOperationInfo.class, boi2); MessagePartInfo mpi = null; for (MessagePartInfo mpi2 : wrappedMessageInfo.getMessageParts()) { if (mpi2.getConcreteName().equals(part.getConcreteName())) { mpi = mpi2; throw new Fault(e);
public void handleMessage(JBIMessage message) throws Fault { Exchange ex = message.getExchange(); Endpoint ep = ex.get(Endpoint.class); BindingOperationInfo boi = ex.get(BindingOperationInfo.class); if (boi == null) { if (message.getJbiExchange().getOperation() != null) { BindingInfo service = ep.getEndpointInfo().getBinding(); boi = getBindingOperationInfo(service, message.getJbiExchange().getOperation()); if (boi == null) { throw new Fault(new Message("UNKNOWN_OPERATION", BUNDLE, message.getJbiExchange().getOperation().toString())); } } else { throw new Fault(new Message("UNKNOWN_OPERATION", BUNDLE, message.getJbiExchange().getInterfaceName().toString())); } ex.put(BindingOperationInfo.class, boi); ex.put(OperationInfo.class, boi.getOperationInfo()); ex.setOneWay(boi.getOperationInfo().isOneWay()); message.put(MessageInfo.class, boi.getInput().getMessageInfo()); } }
public void handleMessage(Message message) throws Fault { W3CDOMStreamWriter domWriter = (W3CDOMStreamWriter)message.getContent(XMLStreamWriter.class); XMLStreamWriter origWriter = (XMLStreamWriter)message .get(LogicalHandlerOutInterceptor.ORIGINAL_WRITER); XMLStreamReader reader = (XMLStreamReader)message.get("LogicalHandlerInterceptor.INREADER"); SOAPMessage origMessage = null; if (reader != null) { message.setContent(Source.class, source); message.setContent(XMLStreamReader.class, StaxUtils.createXMLStreamReader(domWriter.getDocument())); if (requestor) { MessageObserver observer = message.getExchange() .get(MessageObserver.class); if (observer != null) { message.removeContent(XMLStreamReader.class); if (reader != null) { StaxUtils.copy(reader, origWriter); } else if (domWriter.getDocument().getDocumentElement() != null) { StaxUtils.copy(domWriter.getDocument(), origWriter); message.setContent(XMLStreamWriter.class, origWriter); } catch (XMLStreamException e) { throw new Fault(e);
boolean requestor = isRequestor(message); XMLStreamReader reader = (XMLStreamReader)message.get("LogicalHandlerInterceptor.INREADER"); SOAPMessage origMessage = null; if (reader != null) { StaxUtils.createXMLStreamReader(domWriter.getDocument())); Exception ex = new Fault(exception); Message faultMessage = exchange.getOutMessage(); if (null == faultMessage) { faultMessage = exchange.getEndpoint().getBinding().createMessage(faultMessage); exchange.setOutMessage(null); ic.reset(); ic.doIntercept(faultMessage); StaxUtils.copy(reader, origWriter); } else if (domWriter.getDocument().getDocumentElement() != null) { StaxUtils.copy(domWriter.getDocument(), origWriter); throw new Fault(e);
private void readJBIWrapper(DepthXMLStreamReader reader) throws XMLStreamException { QName startQName; if (!StaxUtils.skipToStartOfElement(reader)) { throw new Fault(new org.apache.cxf.common.i18n.Message( "NOT_ENOUGH_PARTS", BUNDLE)); } startQName = reader.getName(); if (!startQName.equals(JBIConstants.JBI_WRAPPER_PART)) { throw new Fault(new org.apache.cxf.common.i18n.Message( "NO_JBI_PART_ELEMENT", BUNDLE)); } }
public void handleMessage(Message message) throws Fault { Exchange ex = message.getExchange(); BindingOperationInfo bop = ex.getBindingOperationInfo(); MessageInfo messageInfo = message.get(MessageInfo.class); if (messageInfo == null || bop == null || !bop.isUnwrapped()) { return; BindingOperationInfo newbop = bop.getWrappedOperation(); MessageInfo wrappedMsgInfo; if (Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE))) { wrappedMsgInfo = newbop.getInput().getMessageInfo(); } else { wrappedMsgInfo = newbop.getOutput().getMessageInfo(); throw f; } catch (Exception e) { throw new Fault(e); ex.put(BindingOperationInfo.class, newbop); if (messageInfo == bop.getOperationInfo().getInput()) {
if (inMessage.getExchange().get(Message.RESPONSE_CODE) == null) { throw t; Endpoint ep = inMessage.getExchange().getEndpoint(); inMessage.getExchange().put(InterceptorProvider.class, getConfiguration()); inMessage.setContent(Exception.class, new Fault(t)); inMessage.getInterceptorChain().abort(); if (ep.getInFaultObserver() != null) { ep.getInFaultObserver().onMessage(inMessage);
/** {@inheritDoc}*/ public Object create(Exchange e) throws Throwable { Service serv = e.getService(); Object o = null; synchronized (serv) { o = e.getSession().get(serv.getName().toString()); if (o == null) { if (createIfNotExist) { o = factory.create(e); e.getSession().put(serv.getName().toString(), o); } else { throw new Fault("COULD_NOT_INSTANTIATE", FactoryInvoker.BUNDLE); } } } return o; }
public void handleMessage(Message msg) { Fault fault = (Fault) msg.getContent(Exception.class); if (fault.getDetail() != null && !MessageUtils.getContextualBoolean(msg, DISABLE_FAULT_MAPPING, false)) { processFaultDetail(fault, msg); setStackTrace(fault, msg); } FaultMode faultMode = FaultMode.UNCHECKED_APPLICATION_FAULT; // Check if the raised exception is declared in the WSDL or by the JAX-RS resource Method m = msg.getExchange().get(Method.class); if (m != null) { Exception e = msg.getContent(Exception.class); for (Class<?> cl : m.getExceptionTypes()) { if (cl.isInstance(e)) { faultMode = FaultMode.CHECKED_APPLICATION_FAULT; break; } } } msg.getExchange().put(FaultMode.class, faultMode); }
public void handleMessage(Message message) throws Fault { String method = (String)message.get(Message.HTTP_REQUEST_METHOD); String query = (String)message.get(Message.QUERY_STRING); if (!"GET".equals(method) || StringUtils.isEmpty(query)) { return; } String baseUri = (String)message.get(Message.REQUEST_URL); URI uri = null; try { uri = URI.create(baseUri); } catch (IllegalArgumentException iae) { //invalid URI, ignore and continue return; } Map<String, String> map = UrlUtils.parseQueryString(query); if (isRecognizedQuery(map, uri, message.getExchange().getEndpoint().getEndpointInfo())) { try { Conduit c = message.getExchange().getDestination().getBackChannel(message); Message mout = new MessageImpl(); mout.setExchange(message.getExchange()); message.getExchange().setOutMessage(mout); mout.put(Message.CONTENT_TYPE, "application/javascript;charset=UTF-8"); c.prepare(mout); OutputStream os = mout.getContent(OutputStream.class); writeResponse(uri, map, os, message.getExchange().getEndpoint()); } catch (IOException ioe) { throw new Fault(ioe); } } }