private Source handleDispatchProviderCase(Service.Mode mode) { Source source = null; Message message = msgContext.getWrappedMessage(); Source obj = message.getContent(Source.class); if (message instanceof SoapMessage) { message.setContent(Source.class, new StreamSource(cos.getInputStream())); } catch (Exception e) { throw new Fault(e); in.close(); } catch (Exception e) { throw new Fault(e); if (obj != null) { source = obj; } else if (message.getContent(DataSource.class) != null) { throw new Fault(new org.apache.cxf.common.i18n.Message( "GETPAYLOAD_OF_DATASOURCE_NOT_VALID_XMLHTTPBINDING", LOG));
private void validatePossibleFault(Message message, BindingOperationInfo bop, Node ds) { Element el = DOMUtils.getFirstElement(ds); if (!"Fault".equals(el.getLocalName())) { return; } message.put(Message.RESPONSE_CODE, 500); el = DOMUtils.getFirstElement(el); while (el != null && !"detail".equals(el.getLocalName())) { el = DOMUtils.getNextElement(el); } if (el != null) { Schema schema = EndpointReferenceUtils.getSchema(message.getExchange().getService() .getServiceInfos().get(0), message.getExchange().getBus()); try { validateFaultDetail(el, schema, bop); } catch (Exception e) { throw new Fault(e); } //We validated what we can from a fault standpoint message.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE); } } private void validateFaultDetail(Element detail, Schema schema, BindingOperationInfo bop) throws Exception {
private void doFromSoapMessage(Message message, Object sm) { SOAPMessage m = (SOAPMessage)sm; MessageContentsList list = (MessageContentsList)message.getContent(List.class); if (list == null) { list = new MessageContentsList(); message.setContent(List.class, list); } Object o = m; if (StreamSource.class.isAssignableFrom(type)) { try { try (CachedOutputStream out = new CachedOutputStream()) { XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out); StaxUtils.copy(new DOMSource(m.getSOAPPart()), xsw); xsw.close(); o = new StreamSource(out.getInputStream()); } } catch (Exception e) { throw new Fault(e); } } else if (SAXSource.class.isAssignableFrom(type)) { o = new StaxSource(new W3CDOMStreamReader(m.getSOAPPart())); } else if (Source.class.isAssignableFrom(type)) { o = new DOMSource(m.getSOAPPart()); } list.set(0, o); }
public void handleMessage(Message message) throws Fault { try { XMLStreamWriter xtw = message.getContent(XMLStreamWriter.class); if (xtw != null) { xtw.writeEndElement(); } } catch (XMLStreamException e) { throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_WRITE_EXC", BUNDLE), e); } }
public void handleMessage(Message message) throws Fault { MessageContentsList outObjects = MessageContentsList.getContentsList(message); Exchange exchange = message.getExchange(); OperationInfo op = exchange.getBindingOperationInfo() == null ? null throw new Fault(new org.apache.cxf.common.i18n.Message("CANNOT_SET_HOLDER_OBJECTS", LOG));
throw new Fault(new org.apache.cxf.common.i18n.Message("ATTACHMENT_NOT_SUPPORTED", LOG, o.getClass()));
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)) Service service = ServiceModelUtil.getService(message.getExchange()); DataBinding dataBinding = service.getDataBinding(); if (dataBinding instanceof WrapperCapableDatabinding) { throw new Fault(e); message.setContent(List.class, newParams);
public void handleMessage(Message message) throws Fault { try { message.getContent(OutputStream.class).close(); } catch (IOException e) { throw new Fault(e); } }
public void performTransformation(Message message) { Reader transformedReader = null; try { transformedReader = XSLTUtils.transform(xsltTemplate, getReader()); IOUtils.copyAndCloseInput(transformedReader, origWriter, IOUtils.DEFAULT_BUFFER_SIZE); message.setContent(Writer.class, origWriter); } catch (IOException e) { throw new Fault("READER_COPY", LOG, e, e.getMessage()); } } }
if (outMessage.getExchange() == null) { return; Message inMessage = outMessage.getExchange().getInMessage(); if (inMessage == null) { return; DelegatingInputStream in = inMessage.getContent(DelegatingInputStream.class); if (PropertyUtils.isTrue(o)) { Collection<Attachment> atts = inMessage.getAttachments(); ((AttachmentDataSource)a.getDataHandler().getDataSource()).cache(inMessage); } catch (IOException e) { throw new Fault(e);
public void handleMessage(Message message) throws Fault { DepthXMLStreamReader xmlReader = getXMLStreamReader(message); try { // put the payload source as a document Document doc = StaxUtils.read(xmlReader); message.setContent(Source.class, new DOMSource(doc)); } catch (XMLStreamException e) { throw new Fault(new org.apache.cxf.common.i18n.Message("XMLSTREAM_EXCEPTION", JUL_LOG), e); } }
} else if (DataSource.class.isAssignableFrom(type)) { MessageContentsList list = (MessageContentsList)message.getContent(List.class); DataSource ds = (DataSource)list.get(0); String ct = ds.getContentType(); if (ct.toLowerCase().contains("multipart/related")) { Message msg = new MessageImpl(); msg.setExchange(message.getExchange()); msg.put(Message.CONTENT_TYPE, ct); try { msg.setContent(InputStream.class, ds.getInputStream()); AttachmentDeserializer deser = new AttachmentDeserializer(msg); deser.initializeAttachments(); } catch (IOException ex) { throw new Fault(ex); final InputStream in = msg.getContent(InputStream.class); final String ct2 = (String)msg.get(Message.CONTENT_TYPE); list.set(0, new DataSource() { out.close(); } catch (IOException e) { throw new Fault(e); ds = new DOMSource(StaxUtils.read(ds)); } catch (XMLStreamException e) { throw new Fault(e);
public void handleMessage(Message message) throws Fault { try { XMLStreamWriter xtw = message.getContent(XMLStreamWriter.class); if (xtw != null) { xtw.writeEndElement(); } } catch (XMLStreamException e) { throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_WRITE_EXC", BUNDLE), e); } }
protected DataWriter<XMLStreamWriter> getDataWriter(Message message) { Service service = ServiceModelUtil.getService(message.getExchange()); DataWriter<XMLStreamWriter> dataWriter = service.getDataBinding().createWriter(XMLStreamWriter.class); if (dataWriter == null) { throw new Fault(new org.apache.cxf.common.i18n.Message("NO_DATAWRITER", BUNDLE, service .getName())); } dataWriter.setAttachments(message.getAttachments()); setDataWriterValidation(service, message, dataWriter); return dataWriter; } private void setDataWriterValidation(Service service, Message message, DataWriter<?> writer) {
public void handleMessage(Message message) { // Map exception Exception exception = message.getContent(Exception.class); Exception mappedException = mapper.map(exception); Fault fault = exception instanceof Fault ? (Fault) exception : null; if (fault == null) { fault = new Fault(exception); message.setContent(Exception.class, fault); } fillInFaultDetails(fault, exception); }
protected BindingOperationInfo getOperation(Message message) { BindingOperationInfo operation = message.getExchange().get(BindingOperationInfo.class); if (operation == null) { throw new Fault(new Exception("Operation not bound on this message")); } return operation; }
@Override public Boolean isWrapped(Method m) { // see if someone overrode the default value if (getServiceFactory().getWrapped() != null) { return getServiceFactory().getWrapped(); } m = getDeclaredMethod(m); SOAPBinding ann = m.getAnnotation(SOAPBinding.class); if (ann != null) { if (ann.style().equals(Style.RPC)) { Message message = new Message("SOAPBinding_MESSAGE_RPC", LOG, m.getName()); throw new Fault(new JaxWsConfigurationException(message)); } return !(ann.parameterStyle().equals(ParameterStyle.BARE)); } return isWrapped(); }
public void handleMessage(Message message) throws Fault { Exchange ex = message.getExchange(); BindingOperationInfo bop = ex.getBindingOperationInfo(); message.setContent(List.class, newObjs); } catch (Fault f) { throw f; } catch (Exception e) { throw new Fault(e);
@Override public void handleMessage(Message message) throws Fault { try { XMLStreamWriter writer = message.getContent(XMLStreamWriter.class); StaxUtils.copy(reader, writer); } catch (XMLStreamException e) { throw new Fault("COULD_NOT_READ_XML_STREAM", LOG, e); } } }
/** * @param message The SOAP message to handle. */ public void handleMessage(SoapMessage message) throws Fault { message.getExchange() .getOutMessage() .setContent(org.apache.cxf.attachment.AttachmentSerializer.class, null); Map<String, List> headers = new HashMap<String, List>(); try { headers.put("User-Agent", Collections.singletonList(message.get("HTTP_HEADER_USER_AGENT"))); message.put(Message.PROTOCOL_HEADERS, headers); } catch (Exception ce) { throw new Fault(ce); } }