/** * same as OutInAxisOperationClient */ public MessageContext getMessageContext(String messageLabel) throws AxisFault { return oc.getMessageContext(messageLabel); }
/** * Returns the message context for a given message label. * * @param messageLabel : label of the message and that can be either "Out" or "In" and nothing else * @return Returns MessageContext. * @throws AxisFault */ @Override public MessageContext getMessageContext(final String messageLabel) throws AxisFault { return oc.getMessageContext(messageLabel); }
/** * same as OutInAxisOperationClient */ public MessageContext getMessageContext(String messageLabel) throws AxisFault { return oc.getMessageContext(messageLabel); }
/** * Returns the message context for a given message label. * * @param messageLabel : * label of the message and that can be either "Out" or "In" and * nothing else * @return Returns MessageContext. * @throws AxisFault */ public MessageContext getMessageContext(String messageLabel) throws AxisFault { return oc.getMessageContext(messageLabel); }
/** * Returns the message context for a given message label. * * @param messageLabel : * label of the message and that can be either "Out" or "In" and * nothing else * @return Returns MessageContext. * @throws AxisFault */ public MessageContext getMessageContext(String messageLabel) throws AxisFault { return oc.getMessageContext(messageLabel); }
//this is the incoming message context MessageContext inMessageContext = MessageContext.getCurrentMessageContext(); OperationContext operationContext = inMessageContext.getOperationContext(); //this is the outgoing message context MessageContext outMessageContext = operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault { SOAPEnvelope resultEnvelope = invokeJavaMethod(msgContext); Object responseMCObject = msgContext.getOperationContext().getMessageContext( WSDLConstants.MESSAGE_LABEL_IN_VALUE); if (responseMCObject != null) { MessageContext responseMC = (MessageContext) responseMCObject; responseMC.setEnvelope(resultEnvelope); } return InvocationResponse.CONTINUE; } private SOAPEnvelope invokeJavaMethod(MessageContext inMessage)
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault { SOAPEnvelope resultEnvelope = invokeJavaMethod(msgContext); Object responseMCObject = msgContext.getOperationContext().getMessageContext( WSDLConstants.MESSAGE_LABEL_IN_VALUE); if (responseMCObject != null) { MessageContext responseMC = (MessageContext) responseMCObject; responseMC.setEnvelope(resultEnvelope); } return InvocationResponse.CONTINUE; } private SOAPEnvelope invokeJavaMethod(MessageContext inMessage)
private boolean isSecurityValidationFault(MessageContext msgCtx) throws AxisFault { OperationContext opCtx = msgCtx.getOperationContext(); MessageContext inMsgCtx; if(opCtx != null && (inMsgCtx = opCtx.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)) != null) { Boolean secErrorFlag = (Boolean) inMsgCtx.getProperty(RampartConstants.SEC_FAULT); if (secErrorFlag != null && secErrorFlag.equals(Boolean.TRUE)) { return true; } } return false; } }
private void ResponseSOAPMessage(OperationContext opCtx, OMElement responseOM) throws AxisFault { MessageContext msgCtxIn = opCtx.getMessageContext("In"); if (!msgCtxIn.getEnvelope().isComplete()) { msgCtxIn.getEnvelope().getBody().getFirstOMChild().close(false); msgCtxIn.getEnvelope().getBody().addChild(responseOM); msgCtxIn.getEnvelope().getBody().getFirstOMChild().detach(); } CommonsTransportHeaders inHeaders = (CommonsTransportHeaders)msgCtxIn.getProperty("TRANSPORT_HEADERS"); if (msgCtxIn.getEnvelope().isComplete()) { System.out.println("SOAP Response:"); System.out.println(msgCtxIn.getEnvelope().toString()); } else { System.out.println("SOAP Response Message Body:"); System.out.println(responseOM.toString()); } }
/** * Remove the indicated message context. * Example Usage: The exchange is aborted and we need to * undo the work and free resources. * @param label * @throws AxisFault */ public void removeMessageContext(String label) throws AxisFault { MessageContext mc = getMessageContext(label); if (mc != null) { messageContexts.remove(label); setComplete(false); touch(); } }
/** * Remove the indicated message context. * Example Usage: The exchange is aborted and we need to * undo the work and free resources. * @param label * @throws AxisFault */ public void removeMessageContext(String label) throws AxisFault { MessageContext mc = getMessageContext(label); if (mc != null) { messageContexts.remove(label); setComplete(false); touch(); } }
private void waitForReply(MessageContext messageContext, DatagramSocket datagramSocket, String contentType) throws IOException { // piggy back message constant is used to pass a piggy back // message context in asnych model if (!(messageContext.getAxisOperation() instanceof OutInAxisOperation) && messageContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) == null) { return; } byte[] inputBuffer = new byte[4096]; //TODO set the maximum size parameter DatagramPacket packet = new DatagramPacket(inputBuffer, inputBuffer.length); datagramSocket.receive(packet); // create the soap envelope try { MessageContext respMessageContext = messageContext.getOperationContext(). getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN); InputStream inputStream = new ByteArrayInputStream(inputBuffer, 0, packet.getLength()); SOAPEnvelope envelope = TransportUtils.createSOAPMessage(respMessageContext, inputStream, contentType); respMessageContext.setEnvelope(envelope); } catch (XMLStreamException e) { throw new AxisFault("Can not build the soap message ", e); } } }
private void waitForReply(MessageContext messageContext, DatagramSocket datagramSocket, String contentType) throws IOException { // piggy back message constant is used to pass a piggy back // message context in asnych model if (!(messageContext.getAxisOperation() instanceof OutInAxisOperation) && messageContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) == null) { return; } byte[] inputBuffer = new byte[4096]; //TODO set the maximum size parameter DatagramPacket packet = new DatagramPacket(inputBuffer, inputBuffer.length); datagramSocket.receive(packet); // create the soap envelope try { MessageContext respMessageContext = messageContext.getOperationContext(). getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN); InputStream inputStream = new ByteArrayInputStream(inputBuffer, 0, packet.getLength()); SOAPEnvelope envelope = TransportUtils.createSOAPMessage(respMessageContext, inputStream, contentType); respMessageContext.setEnvelope(envelope); } catch (XMLStreamException e) { throw new AxisFault("Can not build the soap message ", e); } } }
private void waitForReply(MessageContext messageContext, DatagramSocket datagramSocket, String contentType) throws IOException { // piggy back message constant is used to pass a piggy back // message context in asnych model if (!(messageContext.getAxisOperation() instanceof OutInAxisOperation) && messageContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) == null) { return; } byte[] inputBuffer = new byte[4096]; //TODO set the maximum size parameter DatagramPacket packet = new DatagramPacket(inputBuffer, inputBuffer.length); datagramSocket.receive(packet); // create the soap envelope try { MessageContext respMessageContext = messageContext.getOperationContext(). getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN); InputStream inputStream = new ByteArrayInputStream(inputBuffer, 0, packet.getLength()); SOAPEnvelope envelope = TransportUtils.createSOAPMessage(respMessageContext, inputStream, contentType); respMessageContext.setEnvelope(envelope); } catch (XMLStreamException e) { throw new AxisFault("Can not build the soap message ", e); } } }
private void terminateRMSSequence() throws AxisFault { // set the state as terminated this.state = STATE_TERMINATE; // notify all the waiting threads MercuryMessageContext mercuryMessageContext = null; MessageContext messageContext = null; for (Iterator iter = this.messageBuffer.values().iterator(); iter.hasNext();){ mercuryMessageContext = (MercuryMessageContext) iter.next(); messageContext = mercuryMessageContext.getMessageContext(); if (messageContext.getAxisOperation().getMessageExchangePattern().equals( WSDL2Constants.MEP_URI_OUT_IN)){ MessageContext inMessageContext = messageContext.getOperationContext().getMessageContext( WSDLConstants.MESSAGE_LABEL_IN_VALUE); synchronized(inMessageContext){ inMessageContext.notify(); } } } // terminate offeredRMD sequence if it is there if (this.offeredRMDSequence != null){ this.offeredRMDSequence.terminate(); } }
/** * Get the collection of Header QNames that are registered as being understood. * This assumes that a Set of QNames which indicates what headers are "understood" by * this particular client through the client's programming model (i.e. application * handlers) has been defined and stored on the outbound MessageContext under the * client.UnderstoodHeaders property. * @param msgContext The inbound message context * @return a Set of Header QNames that have been registered as understood, or null if * none have been registered. */ private static Set getUnderstoodClientHeaders(MessageContext msgContext) { Set returnQN = null; // The client sets the property on the JAX-WS Request Message Context, which will be copied // to the Axis2 outbound message context. OperationContext opCtx = msgContext.getOperationContext(); MessageContext outboundMC = null; try { outboundMC = opCtx.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE); } catch (AxisFault af) { // Ignore this; it means that there wasn't an outbound message for this operation. } if (outboundMC != null) { returnQN = (Set) outboundMC.getProperty("client.UnderstoodHeaders"); } return returnQN; }
/** * Helper method to retrieve a property from a specific message context of the operation the given message context * is part of. * * @param currentMsgCtx The current {@link MessageContext} * @param key The name of the property to get the value for * @param flow The flow from which the property should be retrieved as integer represented using the * {@link MessageContext#IN_FLOW} and {@link MessageContext#OUT_FLOW} constants * @return The value of the requested property if it exists in the out flow message context,or <br> * <code>null</code> otherwise. */ private static Object getPropertyFromMsgCtx(final MessageContext currentMsgCtx, final String key, final int flow) { if (currentMsgCtx == null || key == null) return null; try { final OperationContext opContext = currentMsgCtx.getOperationContext(); final MessageContext targetMsgContext = currentMsgCtx.getFLOW() == flow ? currentMsgCtx : opContext.getMessageContext(flow == MessageContext.IN_FLOW ? WSDLConstants.MESSAGE_LABEL_IN_VALUE : WSDLConstants.MESSAGE_LABEL_OUT_VALUE); return targetMsgContext.getProperty(key); } catch (final Exception ex) { return null; } }
/** * Creates the {@link MessageContext} for the response to message currently being processed. * * @param reqContext The MessageContext of the received message * @return The MessageContext for the response message */ public static MessageContext createResponseMessageContext(final MessageContext reqContext) { try { MessageContext resCtx = null; // First try to get the context for the response from the OperationContext final OperationContext opContext = reqContext.getOperationContext(); if (opContext != null) { resCtx = opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE); } // If that fails, construct a new context if (resCtx == null) { resCtx = MessageContextBuilder.createOutMessageContext(reqContext); resCtx.getOperationContext().addMessageContext(resCtx); } return resCtx; } catch (final AxisFault af) { // Somewhere the construction of the new MessageContext failed return null; } } }
private boolean handle202(MessageContext requestMsgContext) throws AxisFault { if (requestMsgContext.isPropertyTrue(NhttpConstants.IGNORE_SC_ACCEPTED)) { // We should not further process this 202 response - Ignore it return true; } MessageReceiver mr = requestMsgContext.getAxisOperation().getMessageReceiver(); MessageContext responseMsgCtx = requestMsgContext.getOperationContext(). getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN); if (responseMsgCtx == null || requestMsgContext.getOptions().isUseSeparateListener()) { // Most probably a response from a dual channel invocation // Inject directly into the SynapseCallbackReceiver requestMsgContext.setProperty(NhttpConstants.HTTP_202_RECEIVED, "true"); mr.receive(requestMsgContext); return true; } return false; }