private void storePayload(LogicalMessageContext context) { Boolean outboundProperty = (Boolean) context .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty) { return; } LogicalMessage logicalMessage = context.getMessage(); Source payloadSource = logicalMessage.getPayload(); this.payload = toString(payloadSource); }
/** * Handle message * @param smc SOAPMessageContext * @return boolean */ public boolean handleMessage(LogicalMessageContext smc) { Boolean outboundProperty = (Boolean) smc .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty.booleanValue()) { startTime = new Date(); smc.put(HandlerName + "StartTime", startTime); } else { try { startTime = (Date) smc.get(HandlerName + "StartTime"); endTime = new Date(); long elapsedTime = endTime.getTime() - startTime.getTime(); smc.put("ELAPSED_TIME", elapsedTime); smc.setScope("ELAPSED_TIME", MessageContext.Scope.APPLICATION); logger.info("Elapsed time in handler " + HandlerName + " is " + elapsedTime); } catch (Exception x) { x.printStackTrace(); } } return true; } }
@Override public boolean invokeLogicalHandlersHandleFault(boolean requestor, LogicalMessageContext context) { if (context.containsKey(KEY)) { return true; } return super.invokeLogicalHandlersHandleFault(requestor, context); }
public final boolean handleMessage(LogicalMessageContext messageContext) { //System.out.println("LogicalMessageHandler handleMessage called"); try { // get the LogicalMessage from our context LogicalMessage msg = messageContext.getMessage(); // check the payload, if its an AddNumbers request, we'll intervene JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); Object payload = msg.getPayload(jaxbContext); Object value = payload; if (payload instanceof JAXBElement) { value = ((JAXBElement)payload).getValue(); } if (value instanceof AddNumbers) { AddNumbers req = (AddNumbers)value; int a = req.getArg0(); req.setArg0(a * 10); msg.setPayload(payload, jaxbContext); } return true; } catch (JAXBException ex) { throw new ProtocolException(ex); } }
public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound) { throw new RuntimeException(clientHandlerMessage); } return true; } };
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); } }
public final boolean handleMessage(LogicalMessageContext messageContext) { //System.out.println("LogicalMessageHandler handleMessage called"); try { // get the LogicalMessage from our context LogicalMessage msg = messageContext.getMessage(); // check the payload, if its an AddNumbers request, we'll intervene JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); Object payload = msg.getPayload(jaxbContext); Object value = payload; if (payload instanceof JAXBElement) { value = ((JAXBElement)payload).getValue(); } if (value instanceof AddNumbers) { AddNumbers req = (AddNumbers)value; int a = req.getArg0(); req.setArg0(a * 10); msg.setPayload(payload, jaxbContext); } return true; } catch (JAXBException ex) { throw new ProtocolException(ex); } }
public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { return false; } return true; } };
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); } }
public class YourHandler implements LogicalHandler{ public boolean handleMessage(LogicalMessageContext context) { boolean inboundProperty= (boolean)context.get(MessageContext.MESSAGE_INBOUND_PROPERTY); if (inboundProperty) { LogicalMessage lm = context.getMessage(); Source payload = lm.getPayload(); Source recodedPayload = modifyEncoding(payload); //This is where you change the encoding. We'll talk more about this lm.setPayload(recodedPayload) //remember to stuff the payload back in there, otherwise your change will not be registered } return true; } }
public boolean handleMessage(LogicalMessageContext ctx) { LogicalMessage msg = ctx.getMessage(); Source payload = msg.getPayload(); assertNotNull(payload); return true; } public boolean handleFault(LogicalMessageContext ctx) {
public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { throw new RuntimeException(clientHandlerMessage); } return true; } };
context.put(OutputStreamMessageContext.ONEWAY_MESSAGE_TF, Boolean.FALSE);
@Override public boolean handleMessage(LogicalMessageContext mc) { HandlerUtils.printMessageContext("Service LogicalHandler", mc); if (Boolean.FALSE.equals(mc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY))) { try { LogicalMessage msg = mc.getMessage(); JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); Object payload = msg.getPayload(jaxbContext); if (payload instanceof DoubleIt) { DoubleIt req = (DoubleIt) payload; if (req.getNumberToDouble() == 30) { throw new ProtocolException( "Doubling 30 is not allowed by the web service provider."); } } } catch (JAXBException ex) { throw new ProtocolException(ex); } } return true; }
private boolean checkServerOutBindStopHandler(boolean outbound, T ctx) { if (outbound) { LogicalMessage msg = ctx.getMessage(); Object obj = msg.getPayload(jaxbCtx); if (obj instanceof PingResponse) { // only check if we need call for the server response handler false PingResponse origResp = (PingResponse)obj; for (String handler : origResp.getHandlersInfo()) { if (handler.indexOf("server") == 0 && handler.indexOf(getHandlerId()) > 0 && handler.indexOf("stop") > 0) { return true; } } } } return false; }
public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { throw new ProtocolException(clientHandlerMessage); } return true; } };
@Override public boolean handleMessage(LogicalMessageContext mc) { LogicalMessage msg = mc.getMessage(); HandlerUtils.printMessageContext("Client LogicalHandler", mc); if (Boolean.TRUE.equals(mc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY))) { Integer maxValue = new Integer((String) mc.get("MAX_VALUE")); try { JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); Object payload = msg.getPayload(jaxbContext); if (payload instanceof DoubleIt) { DoubleIt req = (DoubleIt) payload; if (req.getNumberToDouble() > maxValue.intValue()) { req.setNumberToDouble(maxValue.intValue()); msg.setPayload(req, jaxbContext); } if (req.getNumberToDouble() == 20) { throw new ProtocolException("Doubling 20 is not allowed by the SOAP client."); } } } catch (JAXBException ex) { throw new ProtocolException(ex); } } return true; }
private boolean handlePingMessage(boolean outbound, T ctx) { LogicalMessage msg = ctx.getMessage(); addHandlerId(msg, ctx, outbound); if (checkServerOutBindStopHandler(outbound, ctx)) { return false; } return getHandleMessageRet(); }
public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); assertTrue("wsdl description not found or invalid", isValidWsdlDescription(ctx .get(MessageContext.WSDL_DESCRIPTION))); return true; } };
public boolean handleMessage(LogicalMessageContext ctx) { super.handleMessage(ctx); try { Boolean outbound = (Boolean)ctx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { LogicalMessage msg = ctx.getMessage(); Source source = msg.getPayload(); assertNotNull(source); } } catch (Exception e) { e.printStackTrace(); fail(e.toString()); } return true; } };