Java Code Examples for javax.xml.ws.handler.MessageContext#put()
The following examples show how to use
javax.xml.ws.handler.MessageContext#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestHandlerBase.java From cxf with Apache License 2.0 | 5 votes |
protected List<String> getHandlerInfoList(MessageContext ctx) { List<String> handlerInfoList = null; if (ctx.containsKey("handler.info")) { handlerInfoList = CastUtils.cast((List<?>)ctx.get("handler.info")); } else { handlerInfoList = new ArrayList<>(); ctx.put("handler.info", handlerInfoList); ctx.setScope("handler.info", MessageContext.Scope.APPLICATION); } return handlerInfoList; }
Example 2
Source File: HandlerChainInvoker.java From cxf with Apache License 2.0 | 5 votes |
private void setMessageOutboundProperty(MessageContext context) { context.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, this.outbound); if (logicalMessageContext != null) { logicalMessageContext.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, this.outbound); } if (protocolMessageContext != null) { protocolMessageContext.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, this.outbound); } }
Example 3
Source File: WebServiceContextImplTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSetHttpRequestHeadersScope() { MessageImpl msg = new MessageImpl(); MessageContext context = new WrappedMessageContext(msg); Map<String, List<String>> headers = new HashMap<>(); List<String> values = new ArrayList<>(); values.add("Value1"); headers.put("Header1", values); context.put(MessageContext.HTTP_REQUEST_HEADERS, headers); context.setScope(MessageContext.HTTP_REQUEST_HEADERS, Scope.APPLICATION); }
Example 4
Source File: LoggingHandler.java From juddi with Apache License 2.0 | 4 votes |
private void setFaultReceived(MessageContext context) { context.put(XLT_FAULT, true); }
Example 5
Source File: AttachmentStreamSourceXMLProvider.java From cxf with Apache License 2.0 | 4 votes |
public StreamSource invoke(StreamSource source) { MessageContext mc = wsContext.getMessageContext(); String httpMethod = (String)mc.get(MessageContext.HTTP_REQUEST_METHOD); if ("POST".equals(httpMethod)) { int count = 0; // we really want to verify that a root part is a proper XML as expected try { Document doc = StaxUtils.read(source); count = Integer.parseInt(doc.getDocumentElement().getAttribute("count")); } catch (Exception ex) { // ignore } Map<String, DataHandler> dataHandlers = CastUtils.cast( (Map<?, ?>)mc.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS)); StringBuilder buf = new StringBuilder(); buf.append("<response>"); int i = 0; for (Map.Entry<String, DataHandler> entry : dataHandlers.entrySet()) { if (i++ > count) { break; } try (ByteArrayOutputStream bous = new ByteArrayOutputStream()) { InputStream is = entry.getValue().getInputStream(); IOUtils.copy(is, bous); buf.append("<att contentId=\"" + entry.getKey() + "\">"); buf.append(Base64Utility.encode(bous.toByteArray())); buf.append("</att>"); } catch (IOException ioe) { ioe.printStackTrace(); } } buf.append("</response>"); Map<String, List<String>> respHeaders = CastUtils .cast((Map<?, ?>)mc.get(MessageContext.HTTP_RESPONSE_HEADERS)); if (respHeaders == null) { respHeaders = new HashMap<>(); mc.put(MessageContext.HTTP_RESPONSE_HEADERS, respHeaders); } List<String> contentTypeValues = new ArrayList<>(); contentTypeValues.add("application/xml+custom"); respHeaders.put(Message.CONTENT_TYPE, contentTypeValues); Map<String, DataHandler> outDataHandlers = CastUtils.cast((Map<?, ?>)mc.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS)); byte[] data = new byte[50]; for (int x = 0; x < data.length; x++) { data[x] = (byte)(x + '0'); } DataHandler foo = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream")); outDataHandlers.put("foo", foo); return new StreamSource(new StringReader(buf.toString())); } return source; }
Example 6
Source File: BookStore.java From cxf with Apache License 2.0 | 4 votes |
@WebMethod public void addBooks() { final MessageContext ctx = context.getMessageContext(); ctx.put(MessageContext.HTTP_RESPONSE_CODE, 202); }
Example 7
Source File: BookStore.java From cxf with Apache License 2.0 | 4 votes |
@WebMethod public void addBooks() { final MessageContext ctx = context.getMessageContext(); ctx.put(MessageContext.HTTP_RESPONSE_CODE, 305); }