Method method = ex.get(Method.class); MessageInfo wrappedMessageInfo = message.get(MessageInfo.class); MessageContentsList lst = MessageContentsList.getContentsList(message); if (lst == null) { return; ex.put(BindingOperationInfo.class, boi2); Class<?> wrapperClass = wrapperPart.getTypeClass(); Object wrappedObject = lst.get(wrapperPart.getIndex()); if (wrapperClass == null || wrappedObject == null || (wrapperClass != null && !wrapperClass.isInstance(wrappedObject))) { newParams = new MessageContentsList(helper.getWrapperParts(wrappedObject)); if (mpi != null && lst.hasValue(mpi)) { count++; newParams.put(part, lst.get(mpi)); newParams.clear(); } else if (removes != null) { Collections.sort(removes, Collections.reverseOrder()); for (Integer i : removes) { if (i < newParams.size()) { newParams.remove(i.intValue());
private void doSoap(Message message) { MessageContentsList list = (MessageContentsList)message.getContent(List.class); if (list == null || list.isEmpty()) { return; Object o = list.get(0); if (o instanceof SOAPMessage) { SOAPMessage soapMessage = (SOAPMessage)o; message.put("write.attachments", Boolean.TRUE); Object enc = soapMessage.getProperty(SOAPMessage.CHARACTER_SET_ENCODING); if (enc instanceof String) { message.put(Message.ENCODING, enc);
private void doDataSource(final Message message) { MessageContentsList list = (MessageContentsList)message.getContent(List.class); //reconstitute all the parts into a Mime data source if (message.getAttachments() != null && !message.getAttachments().isEmpty() && list != null && !list.isEmpty() && list.get(0) instanceof DataSource) { list.set(0, new MultiPartDataSource(message, (DataSource)list.get(0))); } }
protected boolean isChunkingSupported(Message message, String httpMethod) { if (HTTP_POST_METHOD.equals(httpMethod)) { return true; } else if (!HTTP_GET_METHOD.equals(httpMethod)) { MessageContentsList objs = MessageContentsList.getContentsList(message); if (objs != null && !objs.isEmpty()) { Object obj = objs.get(0); if (obj.getClass() != String.class || (obj.getClass() == String.class && ((String)obj).length() > 0)) { return true; } } } return false; }
public void handleMessage(Message message) throws Fault { MessageContentsList outObjects = MessageContentsList.getContentsList(message); Exchange exchange = message.getExchange(); OperationInfo op = exchange.getBindingOperationInfo() == null ? null : exchange.getBindingOperationInfo().getOperationInfo(); if (!Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE))) { List<MessagePartInfo> parts = op.getOutput().getMessageParts(); MessageContentsList inObjects = MessageContentsList.getContentsList(exchange.getInMessage()); if (inObjects != null) { if (!(inObjects == outObjects)) { for (int x = 0; x < inObjects.size(); x++) { Object o = inObjects.get(x); if (o instanceof Holder) { outObjects.set(x + 1, o); throw new Fault(new org.apache.cxf.common.i18n.Message("CANNOT_SET_HOLDER_OBJECTS", LOG)); if (part.getIndex() > 0 && part.getTypeClass() != null) { Holder<?> holder = (Holder<?>)outObjects.get(part); outObjects.put(part, holder.value); for (int x = 0; x < outObjects.size(); x++) { Object o = outObjects.get(x); if (o instanceof Holder) { outObjects.set(x, ((Holder<?>)o).value); } else { holders.set(x, null);
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; wrapped = wrappedMsgInfo.getFirstMessagePart().getTypeClass(); MessageContentsList objs = MessageContentsList.getContentsList(message); WrapperHelper helper = firstMessagePart.getProperty("WRAPPER_CLASS", WrapperHelper.class); if (helper == null) { helper = getWrapperHelper(message, messageInfo, wrappedMsgInfo, wrapped, firstMessagePart); MessageContentsList newObjs = new MessageContentsList(); if (ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, message) && helper instanceof AbstractWrapperHelper) { newObjs.put(firstMessagePart, o2); if (Boolean.TRUE.equals(p.getProperty(ReflectionServiceFactoryBean.HEADER))) { MessagePartInfo mpi = wrappedMsgInfo.getMessagePart(p.getName()); if (objs.hasValue(p)) { newObjs.put(mpi, objs.get(p)); ex.put(BindingOperationInfo.class, newbop); if (messageInfo == bop.getOperationInfo().getInput()) {
} 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()); deser.initializeAttachments(); } catch (IOException ex) { throw new Fault(ex); list.set(0, new DataSource() { list.remove(0); XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out); Source ds = (Source)list.get(0); if (!(ds instanceof DOMSource)) { try { ds = new DOMSource(StaxUtils.read(ds)); } catch (XMLStreamException e) { throw new Fault(e); list.set(0, ds); validatePossibleFault(message, bop, ((DOMSource)ds).getNode());
public void handleMessage(Message message) { if (isGET(message) && message.getContent(List.class) != null) { LOG.fine("StaxDataBindingInterceptor skipped in HTTP GET method"); return; MessageContentsList parameters = new MessageContentsList(); Exchange exchange = message.getExchange(); BindingOperationInfo bop = exchange.getBindingOperationInfo(); if (!StaxUtils.toNextElement(xmlReader) && bop != null) { Endpoint ep = exchange.getEndpoint(); bop = ep.getBinding().getBindingInfo().getOperations().iterator().next(); message.getExchange().put(BindingOperationInfo.class, bop); parameters.put(bop.getOutput().getMessageParts().get(0), dr.read(xmlReader)); } else { parameters.put(bop.getInput().getMessageParts().get(0), dr.read(xmlReader)); if (!parameters.isEmpty()) { message.setContent(List.class, parameters);
public void handleMessage(Message message) throws Fault { String method = (String)message.get(Message.HTTP_REQUEST_METHOD); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Invoking HTTP method " + method); LOG.fine("URIMappingInterceptor get operation: " + opName); BindingOperationInfo op = ServiceModelUtil.getOperation(message.getExchange(), opName); if (op == null || opName == null || op.getName() == null || StringUtils.isEmpty(op.getName().getLocalPart()) || !opName.equals(op.getName().getLocalPart())) { if (!Boolean.TRUE.equals(message.getContextualProperty(NO_VALIDATE_PARTS))) { throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OPERATION_PATH", LOG, opName, message.get(Message.PATH_INFO))); MessageContentsList params = new MessageContentsList(); params.add(null); message.setContent(List.class, params); if (op == null) { message.getExchange().put(BindingOperationInfo.class, op); message.getExchange().put(BindingOperationInfo.class, op); MessageContentsList params = getParameters(message, op); message.setContent(List.class, params);
public void handleMessage(Message message) throws Fault { MessageContentsList inObjects = MessageContentsList.getContentsList(message); OperationInfo op = bop.getOperationInfo(); if (op == null || !op.hasOutput() || op.getOutput().size() == 0) { return; boolean client = Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE)); if (client) { List<Holder<?>> outHolders = CastUtils.cast((List<?>)message.getExchange() .getOutMessage().get(CLIENT_HOLDERS)); for (MessagePartInfo part : parts) { if (part.getIndex() != 0 && part.getTypeClass() != null) { @SuppressWarnings("unchecked") Holder<Object> holder = (Holder<Object>)outHolders.get(part.getIndex() - 1); if (holder != null) { holder.value = inObjects.get(part); inObjects.put(part, holder); inObjects = new MessageContentsList(); message.setContent(List.class, inObjects); if (idx >= inObjects.size()) { inObjects.set(idx, new Holder<Object>()); } else { Object o = inObjects.get(idx); inObjects.set(idx, new Holder<Object>(o));
public void handleMessage(Message message) throws Fault { if (PropertyUtils.isTrue(message.getExchange().get(JAXRSUtils.SECOND_JAXRS_EXCEPTION))) { return; final Fault f = (Fault) message.getContent(Exception.class); Response r = JAXRSUtils.convertFaultToResponse(f.getCause(), message); if (r != null) { JAXRSUtils.setMessageContentType(message, r); message.setContent(List.class, new MessageContentsList(r)); if (message.getExchange().getOutMessage() == null && message.getExchange().getOutFaultMessage() != null) { message.getExchange().setOutMessage(message.getExchange().getOutFaultMessage()); message.put(org.apache.cxf.message.Message.RESPONSE_CODE, f.getStatusCode()); NSStack nsStack = new NSStack(); nsStack.push(); if (f.getDetail() != null) { StaxUtils.writeStartElement(writer, prefix, "detail", "http://cxf.apache.org/bindings/xformat"); StaxUtils.writeNode(DOMUtils.getChild(f.getDetail(), Node.ELEMENT_NODE), writer, false);
public void handleMessage(Message message) { if (isGET(message) && message.getContent(List.class) != null) { LOG.fine("StaxDataBindingInterceptor skipped in HTTP GET method"); return; MessageContentsList parameters = new MessageContentsList(); Exchange exchange = message.getExchange(); BindingOperationInfo bop = exchange.get(BindingOperationInfo.class); if (!StaxUtils.toNextElement(xmlReader) && bop != null) { Endpoint ep = exchange.get(Endpoint.class); bop = ep.getBinding().getBindingInfo().getOperations().iterator().next(); message.getExchange().put(BindingOperationInfo.class, bop); parameters.put(bop.getOutput().getMessageParts().get(0), dr.read(xmlReader)); } else { parameters.put(bop.getInput().getMessageParts().get(0), dr.read(xmlReader)); if (parameters.size() > 0) { message.setContent(List.class, parameters);
List<MessagePartInfo> parts) { Object en = message.getContextualProperty(OUT_BUFFERING); boolean allowBuffer = true; boolean buffer = false; && writeToOutputStream(message, operation.getBinding(), service) && !MessageUtils.isTrue(message.getContextualProperty(DISABLE_OUTPUTSTREAM_OPTIMIZATION))) { if (xmlWriter != null) { xmlWriter.flush(); } catch (XMLStreamException e) { throw new Fault(e); if (objs.hasValue(part)) { Object o = objs.get(part); osWriter.write(o, part, out); if (objs.hasValue(part)) { Object o = objs.get(part); dataWriter.write(o, part, xmlWriter); try { for (XMLEvent event : cache.getEvents()) { StaxUtils.writeEvent(event, origXmlWriter); throw new Fault(e);
nsStack.push(); BindingOperationInfo operation = message.getExchange().getBindingOperationInfo(); assert operation.getName() != null; message.setContent(XMLStreamWriter.class, cache); xmlWriter = cache; if (operation.getOutput() == null) { return; parts = operation.getOutput().getMessageParts(); output = true; } else { MessageContentsList objs = MessageContentsList.getContentsList(message); if (objs == null) { addOperationNode(nsStack, message, xmlWriter, output, operation); if (objs.hasValue(part)) { Object o = objs.get(part); if (o == null) { writeParts(message, message.getExchange(), operation, objs, parts); throw new Fault(e);
public static void convertSourceToObject(Message message) { List<Object> content = CastUtils.cast(message.getContent(List.class)); if (content == null || content.size() < 1) { // nothing to convert return; } // only supporting the wrapped style for now (one pojo <-> one source) Source source = (Source)content.get(0); DataReader<XMLStreamReader> reader = message.getExchange().getService().getDataBinding().createReader(XMLStreamReader.class); MessagePartInfo mpi = getMessageInfo(message).getMessagePart(0); XMLStreamReader streamReader = null; Object wrappedObject = null; try { streamReader = StaxUtils.createXMLStreamReader(source); wrappedObject = reader.read(mpi, streamReader); } finally { try { StaxUtils.close(streamReader); } catch (XMLStreamException e) { // Ignore } } MessageContentsList parameters = new MessageContentsList(); parameters.put(mpi, wrappedObject); message.setContent(List.class, parameters); }
final Object serviceObject, Method m, List<Object> params) { JaxwsServerHandler h = exchange.get(JaxwsServerHandler.class); if (h != null && h.isDone()) { BindingOperationInfo bop = exchange.getBindingOperationInfo(); if (bop.isUnwrapped()) { exchange.put(BindingOperationInfo.class, bop.getWrappedOperation()); return new MessageContentsList(h.getObject()); } catch (ExecutionException ex) { exchange.getInMessage().put(FaultMode.class, FaultMode.CHECKED_APPLICATION_FAULT); throw createFault(ex.getCause(), m, params, true); h.waitForDone(); BindingOperationInfo bop = exchange.getBindingOperationInfo(); if (bop.isUnwrapped()) { exchange.put(BindingOperationInfo.class, bop.getWrappedOperation()); return new MessageContentsList(h.getObject()); } catch (ExecutionException ex) { exchange.getInMessage().put(FaultMode.class, FaultMode.CHECKED_APPLICATION_FAULT); throw createFault(ex.getCause(), m, params, true);
public void handleMessage(Message message) throws Fault { if (message.getExchange().get(Throwable.class) != null) { return; } try { Document doc = getDomDocument(message); if (doc == null) { return; } Document finalDoc = processDocument(message, doc); message.setContent(List.class, new MessageContentsList(new DOMSource(finalDoc))); } catch (Exception ex) { StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); LOG.warning(sw.toString()); throw new Fault(new RuntimeException(ex.getMessage() + ", stacktrace: " + sw.toString())); } }
if (!StaxUtils.toNextElement(xmlReader)) { message.setContent(Exception.class, new RuntimeException("There must be a method name element.")); if (message.getExchange().getBindingOperationInfo() == null) { operation = getOperation(message, new QName(xmlReader.getNamespaceURI(), opName)); if (operation == null) { operation = message.getExchange().getBindingOperationInfo(); msg = operation.getOperationInfo().getInput(); } else { msg = operation.getOperationInfo().getOutput(); message.put(MessageInfo.class, msg); MessageContentsList parameters = new MessageContentsList(); StaxUtils.nextEvent(xmlReader); MessagePartInfo part = itr.next(); if (hasNext) { hasNext = StaxUtils.toNextElement(xmlReader); parameters.put(part, dr.read(part, xmlReader)); } catch (Fault f) { if (!isRequestor(message)) { f.setFaultCode(Fault.FAULT_CODE_CLIENT);
private Object handleFault(Fault ex, Message inMessage, ClassResourceInfo cri, Method methodToInvoke) { String errorMessage = ex.getMessage(); if (errorMessage != null && cri != null && errorMessage.contains(PROXY_INVOCATION_ERROR_FRAGMENT)) { org.apache.cxf.common.i18n.Message errorM = new org.apache.cxf.common.i18n.Message("PROXY_INVOCATION_FAILURE", BUNDLE, methodToInvoke, cri.getServiceClass().getName()); LOG.severe(errorM.toString()); } Response excResponse = JAXRSUtils.convertFaultToResponse(ex.getCause() == null ? ex : ex.getCause(), inMessage); if (excResponse == null) { inMessage.getExchange().put(Message.PROPOGATE_EXCEPTION, ExceptionUtils.propogateException(inMessage)); throw ex; } return new MessageContentsList(excResponse); }
protected static List<Source> getPayloadBodyElements(Message message, Map<String, String> nsMap) { Map<String, String> bodyNC = CastUtils.cast((Map<?, ?>)message.get("soap.body.ns.context")); if (bodyNC != null) { Document soapEnv = (Document) message.getContent(Node.class); if (soapEnv != null) { NamedNodeMap attrs = soapEnv.getFirstChild().getAttributes(); MessageContentsList inObjects = MessageContentsList.getContentsList(message); if (inObjects == null) { return new ArrayList<>(0); org.apache.cxf.message.Exchange exchange = message.getExchange(); BindingOperationInfo boi = exchange.getBindingOperationInfo(); OperationInfo op = boi.getOperationInfo(); if (boi.isUnwrapped()) { op = boi.getWrappedOperation().getOperationInfo(); if (!inObjects.hasValue(partInfo)) { continue; Object part = inObjects.get(partInfo);