Package org.jboss.ws.core.jaxws.handler

Examples of org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS


      // Get the order of pre/post handlerchains
      HandlerType[] handlerType = new HandlerType[] { HandlerType.PRE, HandlerType.ENDPOINT, HandlerType.POST };
      HandlerType[] faultType = new HandlerType[] { HandlerType.PRE, HandlerType.ENDPOINT, HandlerType.POST };

      // Associate a message context with the current thread
      CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
      MessageContextAssociation.pushMessageContext(msgContext);
      try
      {
         msgContext.setEndpointMetaData(epMetaData);
         msgContext.setSOAPMessage(reqMsg);
         msgContext.putAll(reqContext);
         // Try to find out the operation metadata corresponding to the message we're sending
         msgContext.setOperationMetaData(getOperationMetaData(epMetaData,reqMsg));

         // The contents of the request context are used to initialize the message context (see section 9.4.1)
         // prior to invoking any handlers (see chapter 9) for the outbound message. Each property within the
         // request context is copied to the message context with a scope of HANDLER.
         msgContext.put(MessageContextJAXWS.MESSAGE_OUTBOUND_PROPERTY, Boolean.TRUE);

         QName portName = epMetaData.getPortName();
         try
         {
            // Call the request handlers
            boolean handlerPass = callRequestHandlerChain(portName, handlerType[0]);
            handlerPass = handlerPass && callRequestHandlerChain(portName, handlerType[1]);
            handlerPass = handlerPass && callRequestHandlerChain(portName, handlerType[2]);

            XOPContext.visitAndRestoreXOPData();

            // Handlers might have replaced the message
            reqMsg = (SOAPMessageImpl)msgContext.getSOAPMessage();

            MessageAbstraction resMsg = null;
            if (handlerPass)
            {
               Map<String, Object> callProps = new HashMap<String, Object>(getRequestContext());
               if (callProps.containsKey(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)) {
                  targetAddress = (String) callProps.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
               }
               EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress, callProps);
               resMsg = getRemotingConnection().invoke(reqMsg, epInfo, false);

               //Pivot, switch to response ctx and save the response message there
               msgContext = MessageContextJAXWS.processPivot(msgContext);
               msgContext.setMessageAbstraction(resMsg);

               // Call the  response handler chain, removing the fault type entry will not call handleFault for that chain
               handlerPass = callResponseHandlerChain(portName, handlerType[2]);
               faultType[2] = null;
               handlerPass = handlerPass && callResponseHandlerChain(portName, handlerType[1]);
View Full Code Here


      return response;
   }

   public void invokeOneWay(T msg)
   {
      CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
      MessageContextAssociation.pushMessageContext(msgContext);
      try
      {
         msgContext.setEndpointMetaData(epMetaData);
         MessageAbstraction reqMsg = getRequestMessage(msg);
         String targetAddress = epMetaData.getEndpointAddress();
         getRemotingConnection().invoke(reqMsg, targetAddress, true);
      }
      catch (Exception ex)
View Full Code Here

      try
      {
         // Construct the endpoint invocation object
         EndpointInvocation epInv = new EndpointInvocation(opMetaData);

         SOAPMessageContextJAXWS msgContext = (SOAPMessageContextJAXWS)MessageContextAssociation.peekMessageContext();
         if (msgContext == null)
            throw new WSException("MessageContext not available");

         ParameterMetaData paramMetaData = opMetaData.getParameters().get(0);
         QName xmlName = paramMetaData.getXmlName();
View Full Code Here

   public MessageAbstraction bindResponseMessage(OperationMetaData opMetaData, EndpointInvocation epInv) throws BindingException
   {
      log.debug("bindResponseMessage: " + opMetaData.getQName());
      try
      {
         SOAPMessageContextJAXWS msgContext = (SOAPMessageContextJAXWS)MessageContextAssociation.peekMessageContext();
         if (msgContext == null)
            throw new WSException("MessageContext not available");

         // Associate current message with message context
         MessageAbstraction resMessage = (MessageAbstraction)epInv.getReturnValue();
         msgContext.setMessageAbstraction(resMessage);

         return resMessage;
      }
      catch (Exception e)
      {
View Full Code Here

   {
      log.debug("bindResponseMessage: " + opMetaData.getQName());

      try
      {
         SOAPMessageContextJAXWS msgContext = (SOAPMessageContextJAXWS)MessageContextAssociation.peekMessageContext();
         if (msgContext == null)
            throw new WSException("MessageContext not available");

         // Associate current message with message context
         MessageFactoryImpl factory = new MessageFactoryImpl();
         factory.setEnvNamespace(Constants.NS_SOAP11_ENV);
         SOAPMessageImpl resMessage = (SOAPMessageImpl)factory.createMessage();
         msgContext.setSOAPMessage(resMessage);

         ParameterMetaData retParameter = opMetaData.getReturnParameter();
         QName xmlName = retParameter.getXmlName();
         SOAPBodyImpl soapBody = (SOAPBodyImpl)resMessage.getSOAPBody();
         SOAPContentElement bodyElement = new SOAPBodyElementDoc(xmlName);
View Full Code Here

         msgContext = new SOAPMessageContextJAXRPC();
         invContext.addAttachment(javax.xml.rpc.handler.MessageContext.class, msgContext);
      }
      else
      {
         msgContext = new SOAPMessageContextJAXWS();
         msgContext.put(MessageContextJAXWS.MESSAGE_OUTBOUND_PROPERTY, new Boolean(false));
         msgContext.put(MessageContextJAXWS.INBOUND_MESSAGE_ATTACHMENTS, new HashMap<String, DataHandler>());
         invContext.addAttachment(javax.xml.ws.handler.MessageContext.class, msgContext);
      }
View Full Code Here

   // Invoked by the proxy invokation handler
   public Object invoke(QName opName, Object[] args, Map<String, Object> resContext) throws RemoteException
   {
      // Associate a message context with the current thread
      CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
      MessageContextAssociation.pushMessageContext(msgContext);

      // The contents of the request context are used to initialize the message context (see section 9.4.1)
      // prior to invoking any handlers (see chapter 9) for the outbound message. Each property within the
      // request context is copied to the message context with a scope of HANDLER.
      Map<String, Object> reqContext = getBindingProvider().getRequestContext();

      if (this.wsrmSequence != null)
      {
         if (RMConstant.PROTOCOL_OPERATION_QNAMES.contains(opName) == false)
         {
            if (this.wsrmSequence.getBackPort() != null)
            {
               // rewrite ReplyTo to use client addressable back port
               Map<String, Object> requestContext = getBindingProvider().getRequestContext();
               AddressingProperties addressingProps = (AddressingProperties)requestContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
               addressingProps.setReplyTo(AddressingBuilder.getAddressingBuilder().newEndpointReference(this.wsrmSequence.getBackPort()));
            }
            Map<String, Object> rmRequestContext = new HashMap<String, Object>();
            List<QName> outMsgs = new LinkedList<QName>();
            wsrmSequence.newMessageNumber();
            outMsgs.add(RMProvider.get().getConstants().getSequenceQName());
            outMsgs.add(RMProvider.get().getConstants().getAckRequestedQName());
            if (wsrmSequence.isAckRequested())
            {
               // piggy backing
               outMsgs.add(RMProvider.get().getConstants().getSequenceAcknowledgementQName());
            }
            rmRequestContext.put(RMConstant.PROTOCOL_MESSAGES, outMsgs);
            rmRequestContext.put(RMConstant.SEQUENCE_REFERENCE, wsrmSequence);
            reqContext.put(RMConstant.REQUEST_CONTEXT, rmRequestContext);
         }
      }

      msgContext.putAll(reqContext);

      try
      {
         Object retObj = invoke(opName, args, false);
         return retObj;
      }
      catch (Exception ex)
      {
         OperationMetaData opMetaData = getOperationMetaData();
         if (opMetaData.isOneWay())
         {
            handleOneWayException(opMetaData, ex);
         }
         else
         {
            handleRemoteException(opMetaData, ex);
         }
         return null;
      }
      finally
      {
         msgContext = MessageContextAssociation.peekMessageContext();
         if (this.wsrmSequence != null)
         {
            if (RMConstant.PROTOCOL_OPERATION_QNAMES.contains(opName) == false)
            {
               Map<String, Object> wsrmResCtx = (Map<String, Object>) msgContext.get(RMConstant.RESPONSE_CONTEXT);
               if (wsrmResCtx != null)
               {
                  RMConstants wsrmConstants = RMProvider.get().getConstants();
                  Map<QName, RMSerializable> mapping = (Map<QName, RMSerializable>)wsrmResCtx.get(RMConstant.PROTOCOL_MESSAGES_MAPPING);
                  QName seq = wsrmConstants.getSequenceQName();
                  if (mapping.keySet().contains(seq))
                  {
                     RMHelper.handleSequenceHeader((RMSequence)mapping.get(seq), this.wsrmSequence);
                  }
                  QName seqAck = wsrmConstants.getSequenceAcknowledgementQName();
                  if (mapping.keySet().contains(seqAck))
                  {
                     RMHelper.handleSequenceAcknowledgementHeader((RMSequenceAcknowledgement)mapping.get(seqAck), this.wsrmSequence);
                  }
                  QName ackReq = wsrmConstants.getAckRequestedQName();
                  if (mapping.keySet().contains(ackReq))
                  {
                     RMHelper.handleAckRequestedHeader((RMAckRequested)mapping.get(ackReq), this.wsrmSequence);
                  }
               }
            }
         }

         // Copy the inbound msg properties to the binding's response context
         for (String key : msgContext.keySet())
         {
            Object value = msgContext.get(key);
            resContext.put(key, value);
         }

         // Reset the message context association
         MessageContextAssociation.popMessageContext();
View Full Code Here

      // Get the order of pre/post handlerchains
      HandlerType[] handlerType = new HandlerType[] { HandlerType.PRE, HandlerType.ENDPOINT, HandlerType.POST };
      HandlerType[] faultType = new HandlerType[] { HandlerType.PRE, HandlerType.ENDPOINT, HandlerType.POST };

      // Associate a message context with the current thread
      CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
      MessageContextAssociation.pushMessageContext(msgContext);
      msgContext.setEndpointMetaData(epMetaData);
      msgContext.setSOAPMessage(reqMsg);
      msgContext.putAll(reqContext);
      // Try to find out the operation metadata corresponding to the message we're sending
      msgContext.setOperationMetaData(getOperationMetaData(epMetaData,reqMsg));
     

      // The contents of the request context are used to initialize the message context (see section 9.4.1)
      // prior to invoking any handlers (see chapter 9) for the outbound message. Each property within the
      // request context is copied to the message context with a scope of HANDLER.
      msgContext.put(MessageContextJAXWS.MESSAGE_OUTBOUND_PROPERTY, Boolean.TRUE);
     
      QName portName = epMetaData.getPortName();
      try
      {
         // Call the request handlers
         boolean handlerPass = callRequestHandlerChain(portName, handlerType[0]);
         handlerPass = handlerPass && callRequestHandlerChain(portName, handlerType[1]);
         handlerPass = handlerPass && callRequestHandlerChain(portName, handlerType[2]);

         // Handlers might have replaced the message
         reqMsg = (SOAPMessageImpl)msgContext.getSOAPMessage();

         MessageAbstraction resMsg = null;
         if (handlerPass)
         {
            Map<String, Object> callProps = new HashMap<String, Object>(getRequestContext());
            if (callProps.containsKey(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)) {
               targetAddress = (String) callProps.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
            }
            EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress, callProps);
            resMsg = getRemotingConnection().invoke(reqMsg, epInfo, false);

            //Pivot, switch to response ctx and save the response message there
            msgContext = MessageContextJAXWS.processPivot(msgContext);
            msgContext.setMessageAbstraction(resMsg);
           
            // Call the  response handler chain, removing the fault type entry will not call handleFault for that chain
            handlerPass = callResponseHandlerChain(portName, handlerType[2]);
            faultType[2] = null;
            handlerPass = handlerPass && callResponseHandlerChain(portName, handlerType[1]);
View Full Code Here

      return response;
   }

   public void invokeOneWay(T msg)
   {
      CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
      MessageContextAssociation.pushMessageContext(msgContext);
      msgContext.setEndpointMetaData(epMetaData);
      try
      {
         MessageAbstraction reqMsg = getRequestMessage(msg);
         String targetAddress = epMetaData.getEndpointAddress();
         getRemotingConnection().invoke(reqMsg, targetAddress, true);
View Full Code Here

/*     */   }
/*     */
/*     */   public Object invoke(QName opName, Object[] args, Map<String, Object> resContext)
/*     */     throws RemoteException
/*     */   {
/* 232 */     CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
/* 233 */     MessageContextAssociation.pushMessageContext(msgContext);
/*     */
/* 238 */     Map reqContext = getBindingProvider().getRequestContext();
/* 239 */     msgContext.putAll(reqContext);
/*     */     try
/*     */     {
/* 243 */       Object retObj = invoke(opName, args, false);
/* 244 */       Object localObject1 = retObj;
/*     */       String key;
/*     */       Object value;
/*     */       return localObject1;
/*     */     }
/*     */     catch (Exception ex)
/*     */     {
/* 248 */       OperationMetaData opMetaData = getOperationMetaData();
/* 249 */       if (opMetaData.isOneWay())
/*     */       {
/* 251 */         handleOneWayException(opMetaData, ex);
/*     */       }
/*     */       else
/*     */       {
/* 255 */         handleRemoteException(opMetaData, ex);
/*     */       }
/* 257 */       Iterator i$ = null;
/*     */       Iterator i$;
/*     */       String key;
/*     */       Object value;
/*     */       return i$;
/*     */     }
/*     */     finally
/*     */     {
/* 262 */       msgContext = MessageContextAssociation.peekMessageContext();
/* 263 */       for (String key : msgContext.keySet())
/*     */       {
/* 265 */         Object value = msgContext.get(key);
/* 266 */         resContext.put(key, value);
/*     */       }
/*     */
/* 270 */       MessageContextAssociation.popMessageContext(); } throw localObject2;
/*     */   }
View Full Code Here

TOP

Related Classes of org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.