private int getReponseCodeFromMessage(Message message) { Integer i = (Integer)message.get(Message.RESPONSE_CODE); if (i != null) { return i.intValue(); } int code = hasNoResponseContent(message) ? HttpURLConnection.HTTP_ACCEPTED : HttpURLConnection.HTTP_OK; // put the code in the message so that others can get it message.put(Message.RESPONSE_CODE, code); return code; }
@Override public void handleMessage(SoapMessage message) throws Fault { HttpServletResponse response = (HttpServletResponse) message.getExchange() .getInMessage().get(AbstractHTTPDestination.HTTP_RESPONSE); response.setStatus(200); // message.put(SoapMessage.RESPONSE_CODE, 200); } }
@Override protected void updateMessageForSuspend() { Message currentMessage = PhaseInterceptorChain.getCurrentMessage(); if (currentMessage.get(WriteListener.class) != null) { // CXF Continuation WriteListener will likely need to be introduced // for NIO supported with non-Servlet specific mechanisms getOutputStream().setWriteListener(currentMessage.get(WriteListener.class)); currentMessage.getInterceptorChain().suspend(); } else { inMessage.getExchange().getInMessage().getInterceptorChain().suspend(); } }
public void handleMessage(Message message) throws Fault { MessageContentsList outObjects = MessageContentsList.getContentsList(message); Exchange exchange = message.getExchange(); OperationInfo op = exchange.getBindingOperationInfo() == null ? null 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)) { message.put(HolderInInterceptor.CLIENT_HOLDERS, holders);
/** * While extracting the Message.PROTOCOL_HEADERS property from the Message, * this call ensures that the Message.PROTOCOL_HEADERS property is * set on the Message. If it is not set, an empty map is placed there, and * then returned. * * @param message The outbound message * @return The PROTOCOL_HEADERS map */ public static Map<String, List<String>> getSetProtocolHeaders(final Message message) { Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS)); if (null == headers) { headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); } else if (headers instanceof HashMap) { Map<String, List<String>> headers2 = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); headers2.putAll(headers); headers = headers2; } message.put(Message.PROTOCOL_HEADERS, headers); return headers; }
public String determineContentType() { String ct = null; List<Object> ctList = CastUtils.cast(headers.get(Message.CONTENT_TYPE)); if (ctList != null && ctList.size() == 1 && ctList.get(0) != null) { ct = ctList.get(0).toString(); } else { ct = (String)message.get(Message.CONTENT_TYPE); } String enc = (String)message.get(Message.ENCODING); if (null != ct) { if (enc != null && ct.indexOf("charset=") == -1 && !ct.toLowerCase().contains("multipart/related")) { ct = ct + "; charset=" + enc; } } else if (enc != null) { ct = "text/xml; charset=" + enc; } else { ct = "text/xml"; } return ct; }
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) { origMessage = message.getContent(SOAPMessage.class); message.setContent(XMLStreamReader.class, reader); message.removeContent(SOAPMessage.class); if (!message.getExchange().isOneWay()) { Endpoint e = message.getExchange().getEndpoint(); Message responseMsg = new MessageImpl(); responseMsg.setExchange(message.getExchange()); responseMsg = e.getBinding().createMessage(responseMsg); .getContent(XMLStreamReader.class)); message.getExchange().setInMessage(responseMsg); responseMsg.put(InterceptorChain.STARTING_AT_INTERCEPTOR_ID, LogicalHandlerInInterceptor.class.getName()); observer.onMessage(responseMsg);
private org.apache.cxf.security.SecurityContext getInternalSecurityContext() { org.apache.cxf.security.SecurityContext sc = m.getContent(org.apache.cxf.security.SecurityContext.class); if (sc == null) { sc = m.get(org.apache.cxf.security.SecurityContext.class); } return sc; } }
public static Message getContextMessage(Message m) { Message contextMessage = m.getExchange() != null ? m.getExchange().getInMessage() : m; if (contextMessage == null && Boolean.FALSE.equals(m.get(Message.INBOUND_MESSAGE))) { contextMessage = m; } return contextMessage; }
private DispatchingRequest getDispatchingRequest(Message message) { Exchange exchange = message.getExchange(); String action = (String) exchange.get(MULE_SOAP_ACTION); Map<String, String> headers = new HashMap<>(); headers.put(SOAP_ACTION, action); // It's important that content type is bundled with the headers headers.put(CONTENT_TYPE, (String) message.get(CONTENT_TYPE)); headers.putAll((Map) exchange.get(MULE_TRANSPORT_HEADERS_KEY)); InputStream content = new ByteArrayInputStream(message.getContent(OutputStream.class).toString().getBytes()); return new DispatchingRequest(content, (String) exchange.get(MULE_WSC_ADDRESS), headers); } }
public void handleMessage(Message message) throws Fault { Fault f = (Fault)message.getContent(Exception.class); if (f == null) { return; SoapVersion soapVersion = (SoapVersion)message.get(SoapVersion.class.getName()); if (soapVersion != null && soapVersion.getVersion() != 1.1) { if (f instanceof SoapFault) { for (Iterator<QName> it = CastUtils.cast(sf.getFault().getFaultSubcodes()); it.hasNext();) { ((SoapFault) f).addSubCode(it.next()); throw new Fault(new org.apache.cxf.common.i18n.Message("COULD_NOT_INVOKE", BUNDLE), e); Service service = message.getExchange().getService(); message.getExchange().getBus()); writer.setSchema(schema); OperationInfo op = message.getExchange().getBindingOperationInfo().getOperationInfo(); QName faultName = getFaultName(fault, cause.getClass(), op); MessagePartInfo part = getFaultMessagePart(faultName, op); FaultMode mode = message.get(FaultMode.class); if (mode == FaultMode.CHECKED_APPLICATION_FAULT) {
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; BindingMessageInfo bmi; MessageInfo wrappedMessageInfo = message.get(MessageInfo.class); MessageInfo messageInfo; if (wrappedMessageInfo == boi.getOperationInfo().getInput()) { return; message.put(MessageInfo.class, messageInfo); message.put(BindingMessageInfo.class, bmi); ex.put(BindingOperationInfo.class, boi2); Service service = ServiceModelUtil.getService(message.getExchange()); DataBinding dataBinding = service.getDataBinding(); if (dataBinding instanceof WrapperCapableDatabinding) {
public void handleMessage(Message message) throws Fault { MessageContentsList inObjects = MessageContentsList.getContentsList(message); Exchange exchange = message.getExchange(); BindingOperationInfo bop = exchange.getBindingOperationInfo(); if (bop == null) { 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) {
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)) { 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()); final InputStream in = msg.getContent(InputStream.class); final String ct2 = (String)msg.get(Message.CONTENT_TYPE); list.set(0, new DataSource() { OutputStream out = message.getContent(OutputStream.class); message.put(Message.CONTENT_TYPE, ct); try { InputStream in = ds.getInputStream();
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; } Endpoint endpoint = message.getExchange().getEndpoint(); synchronized (endpoint) { if (!StringUtils.isEmpty(contextName)) { AuthorizationPolicy policy = message.get(AuthorizationPolicy.class); if (policy == null) { handle401response(message, endpoint); return; } Subject subject = (Subject)authenticate(policy.getUserName(), policy.getPassword()); if (subject == null) { handle401response(message, endpoint); return; } } } }
boolean getRequest = "GET".equals(message.get(Message.HTTP_REQUEST_METHOD)); boolean emptyRequest = getRequest || PropertyUtils.isTrue(message.get(EMPTY_REQUEST_PROPERTY)); Map<String, List<Object>> theHeaders = CastUtils.cast(headers); logProtocolHeaders(LOG, Level.FINE, theHeaders, logSensitiveHeaders());
String scheme = (String)message.get("http.scheme"); final MessageTrustDecider orig = message.get(MessageTrustDecider.class); MessageTrustDecider trust = new HttpsMessageTrustDecider(certConstraints, orig); message.put(MessageTrustDecider.class, trust); } else { throw new UntrustedURLConnectionIOException( TLSSessionInfo tlsInfo = message.get(TLSSessionInfo.class); final Certificate[] certs = tlsInfo.getPeerCertificates(); if (certs == null || certs.length == 0) {
@Override public void handleFault(Message message) { FaultMode mode = message.get(FaultMode.class); Exception exception = message.getContent(Exception.class); if (exception != null && exception.getCause() != null) { if (mode != FaultMode.CHECKED_APPLICATION_FAULT) { if (exception.getCause() instanceof NotificationFailedException) { message.put(FaultMode.class, FaultMode.CHECKED_APPLICATION_FAULT); } } } }
private String getEncoding(Message message) { Exchange ex = message.getExchange(); String encoding = (String)message.get(Message.ENCODING); if (encoding == null && ex.getInMessage() != null) { encoding = (String) ex.getInMessage().get(Message.ENCODING); message.put(Message.ENCODING, encoding); } if (encoding == null) { encoding = "UTF-8"; message.put(Message.ENCODING, encoding); } return encoding; }