You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ja...@apache.org on 2004/05/06 20:43:00 UTC

cvs commit: ws-fx/sandesha/src/org/apache/sandesha/client ClientMessageController.java RMClientReferance.java RMClientService.java

jaliya      2004/05/06 11:43:00

  Modified:    sandesha/src/org/apache/sandesha/client
                        ClientMessageController.java RMClientReferance.java
                        RMClientService.java
  Log:
  Modified Code with Formatting
  
  Revision  Changes    Path
  1.7       +124 -57   ws-fx/sandesha/src/org/apache/sandesha/client/ClientMessageController.java
  
  Index: ClientMessageController.java
  ===================================================================
  RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/client/ClientMessageController.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ClientMessageController.java	3 May 2004 12:52:36 -0000	1.6
  +++ ClientMessageController.java	6 May 2004 18:43:00 -0000	1.7
  @@ -17,108 +17,175 @@
   
   package org.apache.sandesha.client;
   
  +import org.apache.axis.message.addressing.MessageID;
  +
  +import org.apache.sandesha.RMMessage;
   import org.apache.sandesha.RMSequence;
  -import org.apache.sandesha.ws.rm.SequenceAcknowledgement;
   import org.apache.sandesha.ws.utility.Identifier;
   
   import java.util.HashMap;
   import java.util.Map;
   
  +
   /**
  - * class ClientMessageController
  - * 
  - * @author Amila Navarathna
  - * @author Jaliya Ekanayaka
  - * @author Sudar Nimalan
  + * @author
  + * Amila Navarathna<br>
  + * Jaliya Ekanayaka<br>
  + * Sudar Nimalan<br>
  + * (Apache Sandesha Project)
  + *
    */
   public class ClientMessageController {
  -    /**
  -     * Field instance
  -     */
  +	/**
  +	 * Field instance
  +	 */
       private static ClientMessageController instance;
  -
  -    /**
  -     * Field sequenceMap
  -     */
  +	/**
  +	 * Field messageMap
  +	 */
  +    private Map messageMap;
  +	/**
  +	 * Field sequenceMap
  +	 */
       private Map sequenceMap;
  -
  -    /**
  -     * Field seqAck
  -     */
  -    private SequenceAcknowledgement seqAck;
  -
  -    /**
  -     * Constructor ClientMessageController
  -     */
  +	/**
  +	 * Field seqAck
  +	 */
  + 
  +    private Identifier sequenceIdentifier;
  +	
  +	/**
  +	 * Constructor ClientMessageController
  +	 */  
       private ClientMessageController() {
           sequenceMap = new HashMap();
  +        messageMap = new HashMap();
       }
  -
  -    /**
  -     * Method getInstance
  -     * 
  -     * @return 
  -     */
  -    public static ClientMessageController getInstance() {
  -
  -        System.out.println("MessageController::getInstance");
  -
  +    
  +	/**
  +	 * Method getInstance
  +	 * 
  +	 * @return ClientMessageController
  +	 */
  +     public static ClientMessageController getInstance() {
  +       
           if (instance == null) {
               instance = new ClientMessageController();
           }
   
           return instance;
       }
  +    
  +	/**
  +	 * Method retrieveIfMessageExists
  +	 *
  +	 * returns a RMMessage if a message for the message id exists.
  +	 * else return a null value
  +	 * <b>developer must handle the null value returned</b>
  +	 * 
  +	 * @param messageID
  +	 * @return RMMessage
  +	 *
  +	 * 
  +	 */
  +
  +    public RMMessage retrieveIfMessageExists(MessageID messageID) {
  +    	RMMessage rmMessage = (RMMessage)messageMap.get(messageID.toString());
  +        if (rmMessage!= null) {
  +            return rmMessage;
  +        } else {
  +            return null;
  +        }
  +    }
  +
   
       /**
        * Method storeSequence
  -     * <p/>
  +     * 
        * stores a sequence object in the map. Each of these sequence objects
        * consists of one or more message objects.
        * The sequences are stored as the sequenceIdentifier as a key
  +     *
  +     * @param sequence
  +     *
        * 
  -     * @param sequence 
        */
       public void storeSequence(RMSequence sequence) {
  +      
  +        sequenceMap.put(sequence.getSequenceIdetifer().toString(), sequence);
  +    }
  +    
  +	/**
  +	 * Method storeMessage
  +	 * 
  +	 * stores a message object in the map. 
  +	 * The message are stored as the message id as a key
  +	 *
  +	 * @param message
  +	 *
  +	 * 
  +	 */
   
  -        // System.out.println("----------------storeSequence::"+sequence.getSequenceIdetifer());
  -        sequenceMap.put(sequence.getSequenceIdentifier().toString(), sequence);
  +    public void storeMessage(RMMessage message) {
  +        messageMap.put(message.getMessageID().toString(), message);
       }
   
  +
       /**
        * Method retrieveIfSequenceExists
  -     * <p/>
  +     *
        * returns a RMSequence if a sequence for the identifier exists.
        * else return a null value
        * <b>developer must handle the null value returned</b>
  +     * @param identifier
        * 
  -     * @param identifier 
        * @return RMSequence
  +     *
  +     * 
        */
       public RMSequence retrieveIfSequenceExists(Identifier identifier) {
  -
  -        if (sequenceMap.get(identifier.toString()) != null) {
  -            return ((RMSequence) sequenceMap.get(identifier.toString()));
  +    	RMSequence rmSequence = (RMSequence)sequenceMap.get(identifier.getIdentifier().toString());
  +        if (rmSequence != null) {
  +            return rmSequence;
           } else {
               return null;
           }
       }
   
  -    /**
  -     * Method getSeqAck
  -     * 
  -     * @return SequenceAcknowledgement
  -     */
  -    public SequenceAcknowledgement getSeqAck() {
  -        return seqAck;
  -    }
   
  -    /**
  -     * Method setSeqAck
  -     * 
  -     * @param acknowledgement 
  -     */
  -    public void setSeqAck(SequenceAcknowledgement acknowledgement) {
  -        seqAck = acknowledgement;
  -    }
  +    
  +	/**
  +	 * Method removeIfSequenceExists
  +	 * 
  +	 * Search for a sequence and if it exists(means it is in the map),
  +	 * remove it from the map
  +	 * 
  +	 * @param identifier
  +	 * 
  +	 * 
  +	 */
  +	public void removeIfSequenceExists(Identifier identifier) {
  +		if (sequenceMap.get(identifier.toString()) != null) {
  +			sequenceMap.remove(identifier.toString());
  +		}
  +	}
  +	/**
  +	 * Method getSequenceIdentifier
  +	 * 
  +	 * @return Identifier
  +	 */
  +	public Identifier getSequenceIdentifier() {
  +		return sequenceIdentifier;
  +	}
  +
  +	/**
  +	 * Method setSequenceIdentifier
  +	 * 
  +	 * @param  identifier
  +	 * 
  +	 */
  +	public void setSequenceIdentifier(Identifier identifier) {
  +		sequenceIdentifier = identifier;
  +	}
  +
   }
  
  
  
  1.4       +8 -5      ws-fx/sandesha/src/org/apache/sandesha/client/RMClientReferance.java
  
  Index: RMClientReferance.java
  ===================================================================
  RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/client/RMClientReferance.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RMClientReferance.java	2 May 2004 16:53:00 -0000	1.3
  +++ RMClientReferance.java	6 May 2004 18:43:00 -0000	1.4
  @@ -18,11 +18,14 @@
   package org.apache.sandesha.client;
   
   /**
  - * class RMClientReferance
  - * 
  - * @author Amila Navarathna
  - * @author Jaliya Ekanayaka
  - * @author Sudar Nimalan
  + * @author
  + * Amila Navarathna<br>
  + * Jaliya Ekanayaka<br>
  + * Sudar Nimalan<br>
  + * (Apache Sandesha Project)
  + *
    */
  +
   public class RMClientReferance {
  +
   }
  
  
  
  1.8       +445 -429  ws-fx/sandesha/src/org/apache/sandesha/client/RMClientService.java
  
  Index: RMClientService.java
  ===================================================================
  RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/client/RMClientService.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RMClientService.java	4 May 2004 11:43:42 -0000	1.7
  +++ RMClientService.java	6 May 2004 18:43:00 -0000	1.8
  @@ -16,458 +16,474 @@
    */
   package org.apache.sandesha.client;
   
  +import javax.xml.rpc.ServiceException;
  +import javax.xml.soap.SOAPException;
  +
   import org.apache.axis.AxisFault;
   import org.apache.axis.Message;
   import org.apache.axis.client.Call;
   import org.apache.axis.client.Service;
  +import org.apache.axis.components.logger.LogFactory;
   import org.apache.axis.components.uuid.UUIDGen;
   import org.apache.axis.components.uuid.UUIDGenFactory;
  -import org.apache.axis.components.logger.LogFactory;
  -import org.apache.axis.message.MessageElement;
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.addressing.Action;
   import org.apache.axis.message.addressing.Address;
   import org.apache.axis.message.addressing.From;
   import org.apache.axis.message.addressing.MessageID;
  +import org.apache.axis.message.addressing.ReplyTo;
   import org.apache.axis.message.addressing.To;
   import org.apache.axis.types.URI;
  +
  +import org.apache.commons.logging.Log;
   import org.apache.sandesha.Constants;
   import org.apache.sandesha.RMMessage;
   import org.apache.sandesha.RMSequence;
   import org.apache.sandesha.ws.rm.AckRequested;
  -import org.apache.sandesha.ws.rm.AcknowledgementRange;
  +import org.apache.sandesha.ws.rm.CreateSequence;
   import org.apache.sandesha.ws.rm.LastMessage;
   import org.apache.sandesha.ws.rm.MessageNumber;
  +import org.apache.sandesha.ws.rm.RMHeaders;
   import org.apache.sandesha.ws.rm.Sequence;
  -import org.apache.sandesha.ws.rm.SequenceAcknowledgement;
   import org.apache.sandesha.ws.utility.Identifier;
  -import org.apache.commons.logging.Log;
  -
  -import javax.xml.rpc.ServiceException;
  -import javax.xml.soap.SOAPException;
  -import javax.xml.soap.SOAPHeaderElement;
  -import java.util.ArrayList;
  -import java.util.Iterator;
  -import java.util.List;
  -import java.util.Vector;
   
   /**
  - * class RMClientService
  - * 
  - * @author Amila Navarathna
  - * @author Jaliya Ekanayaka
  - * @author Sudar Nimalan
  + * @author
  + * Amila Navarathna<br>
  + * Jaliya Ekanayaka<br>
  + * Sudar Nimalan<br>
  + * (Apache Sandesha Project)
  + *
    */
   public class RMClientService {
  -    /**
  -     * Field log
  -     */
  -    protected static Log log = LogFactory.getLog(RMClientService.class.getName());
  -
  -    /**
  -     * Field retransmissinInterval
  -     */
  -    private long retransmissionInterval;
  -
  -    /**
  -     * Field retransmissionCount
  -     */
  -    private int retransmissionCount;
  -
  -    /**
  -     * Constructor RMClientService
  -     */
  -    public RMClientService() {
  -        retransmissionInterval = Constants.RETRANSMISSION_INTERVAL;
  -    }
  -
  -    /**
  -     * Method clientMethod
  -     * 
  -     * @param reqSOAPEnvelop     
  -     * @param sequenceID         
  -     * @param destinationURL     
  -     * @param toClientServiceURL 
  -     * @param isOneWay           
  -     * @param isLastMessage      
  -     * @param isCreateSequence   
  -     * @param isResponseExpected 
  -     * @return 
  -     */
  -    public String clientMethod(String reqSOAPEnvelop, String sequenceID,
  -                               String destinationURL,
  -                               String toClientServiceURL, String isOneWay,
  -                               String isLastMessage, String isCreateSequence,
  -                               String isResponseExpected) throws AxisFault {
  -
  -        // create a Identifier object from the sequenceID
  -        Identifier identifier = new Identifier();
  -
  -        identifier.setIdentifier(sequenceID);
  -
  -        // create the message
  -        Message message = new Message(reqSOAPEnvelop);
  -        RMMessage rmMessage = new RMMessage(message);
  -
  -        rmMessage.setDestinationURL(destinationURL);
  -        rmMessage.setToClientServiceURL(toClientServiceURL);
  -        rmMessage.setIsOneWay(isOneWay);
  -        rmMessage.setIsCreateSequence(isCreateSequence);
  -        rmMessage.setIsResponseExpected(isResponseExpected);
  -        rmMessage.setIdentifier(identifier);
  -
  -        // get the singleton instance
  -        ClientMessageController controller =
  -                ClientMessageController.getInstance();
  -        RMSequence sequence =
  -                controller.retrieveIfSequenceExists(identifier);
  -
  -        if (sequence == null) {    // means there is no sequence
  -            sequence = new RMSequence(identifier);
  -
  -            // add this message to the sequence
  -            // sequence.getNextMessageNo();
  -            sequence.insertClientMessage(rmMessage);
  -            controller.storeSequence(sequence);
  -        } else {                   // means that there exists a sequence for this identifier
  -            sequence.insertClientMessage(rmMessage);
  -        }
  -
  -        String stringReturn = null;
  -
  -        if (isCreateSequence.compareTo("true") == 0) {
  -            if (isOneWay.compareTo("true") == 0) {
  -                if (isResponseExpected.compareTo("true") == 0) {
  -
  -                    // need to wait for to return.
  -                    // call. invoke and handle the exception when terminating the HTTP
  -                    // put the message in to the singleton.
  -                } else {
  -
  -                    // error no way for client to be contacted.
  -                }
  -            } else {
  -
  -                // Call.invoke a but with anonymous url, Same HTTP:\
  -                // Return when we get the thing.
  -                // put the message in to the singleton and let the retransmission to happen.
  -            }
  -        } else {
  -            if (isOneWay.compareTo("true") == 0) {
  -                if (isResponseExpected.compareTo("true") == 0) {
  -
  -                    // need to wait for to return.
  -                    // call. invoke and handle the exception when terminating the HTTP
  -                    // put to the singleton and then wait
  -                } else {
  -
  -                    // call. invoke and handle the exception when terminating the HTTP
  -                    // can return.  wait for ack no return.
  -                }
  -            } else {
  -                if (isResponseExpected.compareTo("true") == 0) {
  -
  -                    // need to wait for to return. ack will come with the return
  -                    // put to the singleton and then wait
  -                } else {
  -
  -                    // System.out.println(isOneWay);
  -                    // ystem.out.println(    "isOneWay.compareTo(true)"+ isOneWay.compareTo("true"));
  -                    try {
  -
  -                        // Crate amessage using the reqSOAPEnvelop string parameter.
  -                        Message msg = new Message(reqSOAPEnvelop);
  -
  -                        // Get the envelop using the message.
  -                        SOAPEnvelope requestEnvelop = msg.getSOAPEnvelope();
  -                        SOAPEnvelope envelopToSend = new SOAPEnvelope();
  -
  -                        envelopToSend.setSchemaVersion(requestEnvelop.getSchemaVersion());
  -                        envelopToSend.setSoapConstants(requestEnvelop.getSOAPConstants());
  -                        envelopToSend.setBody((org.apache.axis.message.SOAPBody) requestEnvelop.getBody());
  -                        envelopToSend.addNamespaceDeclaration(Constants.NS_PREFIX_RM, Constants.NS_URI_RM);
  -                        envelopToSend.addNamespaceDeclaration(org.apache.axis.message.addressing.Constants.NS_PREFIX_ADDRESSING,
  -                                org.apache.axis.message.addressing.Constants.NS_URI_ADDRESSING);
  -                        envelopToSend.addNamespaceDeclaration(Constants.WSU_PREFIX,
  -                                Constants.WSU_NS);
  -
  -                        // New envelop to create the SOAP envelop to send. Why use of two envelop is not clear.
  -                        // adding the name spaces to the env
  -                        // now get the sequence element
  -                        Sequence seqElement = new Sequence();
  -
  -                        seqElement.setIdentifier(identifier);
  -
  -                        MessageNumber msgNumber = new MessageNumber();
  -
  -                        msgNumber.setMessageNumber(rmMessage.getMessageNumber());
  -
  -                        if (isLastMessage.equals("true")) {
  -                            LastMessage lastMessage = new LastMessage();
  -
  -                            seqElement.setLastMessage(lastMessage);
  -                        }
  -
  -                        seqElement.setMessageNumber(msgNumber);
  -
  -                        // add the sequence element to the envelop to send
  -                        seqElement.toSoapEnvelop(envelopToSend);
  -
  -                        // set the action
  -                        URI actionURI = new URI("urn:wsrm:Ping");
  -                        Action action = new Action(actionURI);
  -
  -                        action.toSOAPHeaderElement(envelopToSend);
  -
  -                        // Set from address.
  -                        // System.out.println(toClientServiceURL);
  -                        URI fromAddressURI = new URI(toClientServiceURL);
  -                        Address fromAddress = new Address(fromAddressURI);
  -
  -                        // Set the from header.
  -                        From from = new From(fromAddress);
  -
  -                        from.toSOAPHeaderElement(envelopToSend);
  -
  -                        UUIDGen uuidGen = UUIDGenFactory.getUUIDGen();
  -                        URI messageIDURI = new URI("uuid:"
  -                                + uuidGen.nextUUID());
  -                        MessageID messageID = new MessageID(messageIDURI);
  -
  -                        messageID.toSOAPHeaderElement(envelopToSend);
  -
  -                        // Set the to address.
  -                        // System.out.println(destinationURL);
  -                        URI toAddress = new To(destinationURL);
  -                        To to = new To(toAddress);
  -
  -                        to.toSOAPHeaderElement(envelopToSend);
  -
  -                        // now store this new message in the rmMessage
  -                        // so that it can be used for retrasmission
  -                        Message newMessage = new Message(envelopToSend);
  -
  -                        rmMessage.setRequestMessage(newMessage);
  -
  -                        // Invoke the expected service.
  -                        Service service = new Service();
  -                        Call call = (Call) service.createCall();
  -
  -                        call.setTargetEndpointAddress(destinationURL);
  -
  -                        // System.out.println("just before invoke 00000");
  -                        // System.out.println();
  -                        // System.out.println(
  -                        // "@@@@@@@@@@@@@@@ BeforeEnvoking from ClientService @@@@@@@@@@@@@@@@@@@@@@@@@");
  -                        // System.out.println(envelopToSend.toString());
  -                        // System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
  -                        // System.out.println();
  -                        // invoke for the first time
  -                        try {
  -                            call.invoke(envelopToSend);
  -
  -                            // System.out.println("the retransmisssion 55555555555" + rmMessage.getIdentifier().toString());
  -                        } catch (Exception e) {
  -                            System.out.println("The exception after invokeWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
  -                            e.printStackTrace();
  -                        }
  -
  -                        boolean gotResponce = false;
  -                        int count = 0;
  -                        Message tempMessage =
  -                                rmMessage.getRequestMessage();
  -                        AckRequested ackRequested = new AckRequested();
  -
  -                        ackRequested.setIdentifier(rmMessage.getIdentifier());
  -
  -                        SOAPEnvelope retransmissionEnvelop =
  -                                tempMessage.getSOAPEnvelope();
  -
  -                        // System.out.println(   "tempMessage.getSOAPEnvelope()" + retransmissionEnvelop.toString());
  -                        System.out.println(ackRequested.getIdentifier().toString());
  -                        ackRequested.toSoapEnvelop(retransmissionEnvelop);
  -
  -                        // System.out.println(retransmissionEnvelop.toString());
  -                        while (count < Constants.MAXIMUM_RETRANSMISSION_COUNT) {
  -                            count++;
  -
  -                            System.out.println("Retransmission ................................................>> "
  -                                    + count);
  -                            System.out.println();
  -                            Thread.sleep(2000);
  -
  -                            if (!rmMessage.isAcknowledged()) {
  -                                Message retransmissionMessage =
  -                                        new Message(retransmissionEnvelop);
  -                                Service retransmissionService = new Service();
  -                                Call retransmissionCall =
  -                                        (Call) service.createCall();
  -
  -                                retransmissionCall.setTargetEndpointAddress(destinationURL);
  -
  -                                try {
  -                                    retransmissionCall.invoke(envelopToSend);
  -
  -                                    // System.out.println("invoked");
  -                                } catch (Exception e) {
  -
  -                                    // Not handle let finlly to handle it.
  -                                }
  -
  -                                continue;
  -
  -                                // /retransmete
  -                            }
  -
  -                            if (new Boolean(rmMessage.getIsResponseExpected()).booleanValue()) {
  -                                if (rmMessage.getResponseMessage() != null) {
  -                                    gotResponce = true;
  -
  -                                    try {
  -                                        stringReturn =
  -                                                rmMessage.getResponseMessage().getSOAPPartAsString();
  -                                    } catch (AxisFault e2) {
  -                                        log.error(e2);
  -                                    }
  -
  -                                    break;
  -                                }
  -                            } else {
  -                                break;
  -                            }
  -                        }
  -
  -                        if (!gotResponce) {
  -                            try {
  -                                SOAPEnvelope env = new SOAPEnvelope();
  -
  -                                stringReturn = env.getAsString();
  -
  -                                System.out.println("GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG");
  -                                System.out.println(stringReturn);
  -                            } catch (Exception e1) {
  -                                log.error(e1);
  -                            }
  -                        }
  -
  -                        // /System.out.println(stringReturn);
  -                        // Not handle let finlly to handle it.
  -                    } catch (ServiceException e) {
  -                        log.error(e);
  -                        throw AxisFault.makeFault(e);
  -                    } catch (SOAPException e) {
  -                        log.error(e);
  -                        throw AxisFault.makeFault(e);
  -                    } catch (Exception e) {
  -                        // If it is comming to this location then there will be an severe error than the
  -                        // HTTP termination.
  -                        log.error(e);
  -                        throw AxisFault.makeFault(e);
  -                    }
  -                }
  -            }
  -        }
  -
  -        System.out.println("Before returning no exception no exception no exception ...");
  -
  -        return stringReturn;
  -    }
  -
  -    /**
  -     * Method ackMethod
  -     * 
  -     * @param sequenceIdentifier 
  -     * @param messageNumber      
  -     */
  -    public void ackMethod(String sequenceIdentifier, String messageNumber) {
  -
  -        // TODO: check the returned string fot the ack range and other elements
  -        // Check for sequenceId
  -        // put the ack in to the singleton and return.
  -
  -        /*
  -         * Identifier identifier = new Identifier();
  -         * identifier.setIdentifier(sequenceIdentifier);
  -         *
  -         * //  get the singleton instance
  -         * ClientMessageController controller =
  -         * ClientMessageController.getInstance();
  -         *
  -         * RMSequence sequence = controller.retrieveIfSequenceExists(identifier);
  -         * RMMessage message = sequence.retrieveMessage(new Long(messageNumber));
  -         *
  -         * if (message != null) {
  -         * message.setAcknowledged(true);
  -         * sequence.insertClientMessage(message);
  -         * }
  -         */
  -    }
  -
  -    /**
  -     * set the acknowledged messages as acknowledged=true and
  -     * put them back in the data structure
  -     * 
  -     * @param identifier 
  -     * @param message    
  -     * @throws AxisFault 
  -     */
  -    private void setAckedMessages(Identifier identifier, Message message)
  -            throws AxisFault {
  -
  -        List ackRangeList = new ArrayList();
  -        SOAPHeaderElement header = null;
  -        SOAPEnvelope envelop = message.getSOAPEnvelope();
  -        Vector headers = envelop.getHeaders();
  -        Iterator ite = headers.iterator();
  -
  -        while (ite.hasNext()) {
  -            header = (SOAPHeaderElement) ite.next();
  -
  -            if (header.getLocalName() == "SequenceAcknowledgement") {
  -                break;
  -            }
  -        }
  -
  -        if (header != null) {
  -            Iterator childIte = header.getChildElements();
  -
  -            while (childIte.hasNext()) {
  -                MessageElement element = (MessageElement) childIte.next();
  -
  -                if (element != null) {
  -                    if (element.getLocalName() == "AcknowledgementRange") {
  -                        String upper =
  -                                element.getAttributeValue("Upper");
  -                        String lower =
  -                                element.getAttributeValue("Lower");
  -                        AcknowledgementRange ackRange =
  -                                new AcknowledgementRange();
  -
  -                        ackRange.setMaxValue(new Long(upper).longValue());
  -                        ackRange.setMinValue(new Long(lower).longValue());
  -                        ackRangeList.add(ackRange);
  -                    }
  -                }
  -            }
  -        }
  -
  -        // now set that ackRangeList in the SequenceAcknowledgement
  -        SequenceAcknowledgement seqAck = new SequenceAcknowledgement();
  -
  -        seqAck.setAckRanges(ackRangeList);
  -
  -        // now add this SequenceAcknowledgement to the RMSequence
  -        // get the singleton instance
  -        ClientMessageController controller =
  -                ClientMessageController.getInstance();
  -        RMSequence sequence =
  -                controller.retrieveIfSequenceExists(identifier);
  -
  -        if (sequence != null) {
  -            sequence.setSeqAck(seqAck);
  -
  -            // now actual update goes
  -            sequence.updateAckedMessages(seqAck);
  -        }
  -    }
  +
  +	/**
  +	 * Field log
  +	 */
  +	protected static Log log = LogFactory.getLog(RMSequence.class.getName());
  +
  +	/**
  +	 * Method clientMethod
  +	 * 
  +	 * @param reqSOAPEnvelop     
  +	 * @param sequenceID         
  +	 * @param destinationURL     
  +	 * @param sourceURL 
  +	 * @param isSynchronous           
  +	 * @param isLastMessage 
  +	 * @param isResponseExpected 
  +	 * @param action
  +	 * @param replyTo
  +	 * 
  +	 * @return String
  +	 */
  +	public String clientMethod(
  +		String reqSOAPEnvelop,
  +		String sequenceID,
  +		String destinationURL,
  +		String sourceURL,
  +		String isSynchronous,
  +		String isLastMessage,
  +		String isResponseExpected,
  +		String action,
  +		String replyTo)
  +		throws SOAPException, ServiceException, AxisFault {
  +
  +		String stringReturn = null;
  +		ClientMessageController clientMessageController =
  +			ClientMessageController.getInstance();
  +		UUIDGen uuidGen = UUIDGenFactory.getUUIDGen();
  +
  +		try {
  +
  +			if (sequenceID.equals("")) {
  +				if ((clientMessageController.getSequenceIdentifier()
  +					== null)) {
  +
  +					URI messageIDURIForCreateSequence;
  +					messageIDURIForCreateSequence =
  +						new URI("uuid:" + uuidGen.nextUUID());
  +					MessageID messageIDForCreateSequence =
  +						new MessageID(messageIDURIForCreateSequence);
  +					SOAPEnvelope envelopToSend =
  +						getSimpleEnvelope(
  +							Constants.ACTION_CREATE_SEQUENCE,
  +							messageIDForCreateSequence);
  +
  +					Address anonymousAddress =
  +						new Address(Constants.ANONYMOUS_URI);
  +					ReplyTo replyToForCreateSequence =
  +						new ReplyTo(anonymousAddress);
  +					replyToForCreateSequence.toSOAPHeaderElement(envelopToSend);
  +
  +					To toForCreateSequence = new To(destinationURL);
  +					toForCreateSequence.toSOAPHeaderElement(envelopToSend);
  +
  +					CreateSequence createSequence = new CreateSequence();
  +					createSequence.toSoapEnvelop(envelopToSend);
  +
  +					Call call = new Call(destinationURL);
  +					call.setRequestMessage(new Message(envelopToSend));
  +					call.invoke();
  +					SOAPEnvelope responseEnvelope =
  +						call.getResponseMessage().getSOAPEnvelope();
  +					RMHeaders rmHeaders = new RMHeaders();
  +					rmHeaders.fromSOAPEnvelope(responseEnvelope);
  +					Identifier tempIdentifier =
  +						rmHeaders.getCreateSequenceResponse().getIdentifier();
  +
  +					if (tempIdentifier != null) {
  +						sequenceID = tempIdentifier.getIdentifier();
  +						clientMessageController.setSequenceIdentifier(
  +							tempIdentifier);
  +					} else {
  +						throw new AxisFault("No Response for Create Sequence Request..");
  +					}
  +
  +				} else {
  +					sequenceID =
  +						clientMessageController
  +							.getSequenceIdentifier()
  +							.getIdentifier();
  +				}
  +			}
  +
  +			Identifier identifier = new Identifier();
  +			identifier.setIdentifier(sequenceID);
  +			Message message = new Message(reqSOAPEnvelop);
  +			RMMessage rmMessage = new RMMessage(message);
  +
  +			rmMessage.setDestinationURL(destinationURL);
  +			rmMessage.setToClientServiceURL(sourceURL);
  +			rmMessage.setIsOneWay(isSynchronous);
  +
  +			rmMessage.setIsResponseExpected(isResponseExpected);
  +			rmMessage.setIdentifier(identifier);
  +
  +			URI messageIDURI = new URI("uuid:" + uuidGen.nextUUID());
  +			MessageID messageID = new MessageID(messageIDURI);
  +			rmMessage.setMessageID(messageID);
  +
  +			RMSequence sequence =
  +				clientMessageController.retrieveIfSequenceExists(identifier);
  +
  +			if (sequence == null) { //means there is no sequence
  +				sequence = new RMSequence(identifier);
  +				//add this message to the sequence
  +				sequence.insertClientMessage(rmMessage);
  +				clientMessageController.storeSequence(sequence);
  +				//Store the message with messageID to be used in <relatesTo>
  +				clientMessageController.storeMessage(rmMessage);
  +			} else {
  +				//means that there exists a sequence for this identifier
  +				sequence.insertClientMessage(rmMessage);
  +				//Store the message with messageID to be used in <relatesTo>
  +				clientMessageController.storeMessage(rmMessage);
  +			}
  +
  +			if (isSynchronous.equals("true")) {
  +				//TODO: normal invocation. but for future...
  +				SOAPEnvelope syncReqEnv =
  +					getInitialMessageWithRMHeaders(
  +						reqSOAPEnvelop,
  +						rmMessage,
  +						identifier,
  +						destinationURL,
  +						Constants.ANONYMOUS_URI,
  +						isLastMessage,
  +						isResponseExpected,
  +						action,
  +						replyTo);
  +
  +				CreateSequence createSqe = new CreateSequence();
  +				createSqe.toSoapEnvelop(syncReqEnv);
  +
  +				Service service = new Service();
  +				Call call = (Call) service.createCall();
  +				call.setTargetEndpointAddress(destinationURL);
  +				call.invoke(syncReqEnv);
  +				stringReturn = call.getResponseMessage().getSOAPPartAsString();
  +
  +			} else {
  +
  +				if (isResponseExpected.equals("true")) {
  +					//Response Expected
  +					SOAPEnvelope envelopToSend =
  +						getInitialMessageWithRMHeaders(
  +							reqSOAPEnvelop,
  +							rmMessage,
  +							identifier,
  +							destinationURL,
  +							sourceURL,
  +							isLastMessage,
  +							isResponseExpected,
  +							action,
  +							replyTo);
  +
  +					Message newMessage = new Message(envelopToSend);
  +					rmMessage.setRequestMessage(newMessage);
  +
  +					//Invoke the expected service.
  +					Service service = new Service();
  +					Call call = (Call) service.createCall();
  +					call.setTargetEndpointAddress(destinationURL);
  +					call.invoke(envelopToSend);
  +
  +					boolean gotResponce = false;
  +					int count = 0;
  +
  +					Message tempMessage = rmMessage.getRequestMessage();
  +					AckRequested ackRequested = new AckRequested();
  +					ackRequested.setIdentifier(rmMessage.getIdentifier());
  +					SOAPEnvelope retransmissionEnvelop =
  +						tempMessage.getSOAPEnvelope();
  +
  +					ackRequested.toSoapEnvelop(retransmissionEnvelop);
  +
  +					while (count < Constants.MAXIMUM_RETRANSMISSION_COUNT) {
  +						count++;
  +						//TODO:
  +						Thread.sleep(2000);
  +
  +						if (new Boolean(rmMessage.getIsResponseExpected())
  +							.booleanValue()) {
  +
  +							if (rmMessage.getResponseMessage() != null) {
  +								gotResponce = true;
  +								stringReturn =
  +									rmMessage
  +										.getResponseMessage()
  +										.getSOAPPartAsString();
  +								break;
  +							}
  +						} else {
  +							break;
  +						}
  +
  +						if (!rmMessage.isAcknowledged()) {
  +
  +							Message retransmissionMessage =
  +								new Message(retransmissionEnvelop);
  +							Service retransmissionService = new Service();
  +							Call retransmissionCall =
  +								(Call) service.createCall();
  +							retransmissionCall.setTargetEndpointAddress(
  +								destinationURL);
  +							retransmissionCall.invoke(envelopToSend);
  +
  +						}
  +
  +					}
  +
  +					if (!gotResponce) {
  +						throw new Exception("No Response from the Service");
  +					}
  +
  +				} else {
  +					//No Response
  +					SOAPEnvelope envelopToSend =
  +						getInitialMessageWithRMHeaders(
  +							reqSOAPEnvelop,
  +							rmMessage,
  +							identifier,
  +							destinationURL,
  +							sourceURL,
  +							isLastMessage,
  +							isResponseExpected,
  +							action,
  +							replyTo);
  +
  +					Message newMessage = new Message(envelopToSend);
  +					rmMessage.setRequestMessage(newMessage);
  +					//Invoke the expected service.
  +					Service service = new Service();
  +					Call call = (Call) service.createCall();
  +					call.setTargetEndpointAddress(destinationURL);
  +					call.invoke(envelopToSend);
  +
  +					boolean gotResponce = false;
  +					int count = 0;
  +					Message tempMessage = rmMessage.getRequestMessage();
  +					AckRequested ackRequested = new AckRequested();
  +					ackRequested.setIdentifier(rmMessage.getIdentifier());
  +					SOAPEnvelope retransmissionEnvelop =
  +						tempMessage.getSOAPEnvelope();
  +					ackRequested.toSoapEnvelop(retransmissionEnvelop);
  +
  +					while (count < Constants.MAXIMUM_RETRANSMISSION_COUNT) {
  +						count++;
  +						//Wait for RETRANSMISSION_INTERVAL
  +						Thread.sleep(Constants.RETRANSMISSION_INTERVAL);
  +						if (!rmMessage.isAcknowledged()) {
  +							Message retransmissionMessage =
  +								new Message(retransmissionEnvelop);
  +							Service retransmissionService = new Service();
  +							Call retransmissionCall =
  +								(Call) service.createCall();
  +							retransmissionCall.setTargetEndpointAddress(
  +								destinationURL);
  +							retransmissionCall.invoke(envelopToSend);
  +
  +						} else {
  +							break;
  +						}
  +					}
  +
  +					stringReturn = null;
  +
  +				}
  +
  +			}
  +
  +			if (isLastMessage.equals("true")) {
  +				clientMessageController.setSequenceIdentifier(null);
  +			}
  +		} catch (Exception e) {
  +			System.out.println(e.toString());
  +			log.error(e);
  +		}
  +
  +		return stringReturn;
  +
  +	}
  +
  +	/**
  +	 * Method getInitialMessageWithRMHeaders
  +	 * 
  +	 * @param reqSOAPEnvelop
  +	 * @param rmMessage
  +	 * @param identifier
  +	 * @param destinationURL
  +	 * @param toClientServiceURL
  +	 * @param isResponseExpected
  +	 * @param strAction
  +	 * @param strReplyTo
  +	 * 	
  +	 * @return SOAPEnvelope
  +	 */
  +
  +	private SOAPEnvelope getInitialMessageWithRMHeaders(
  +		String reqSOAPEnvelop,
  +		RMMessage rmMessage,
  +		Identifier identifier,
  +		String destinationURL,
  +		String toClientServiceURL,
  +		String isLastMessage,
  +		String isResponseExpected,
  +		String strAction,
  +		String strReplyTo) throws Exception {
  +
  +		SOAPEnvelope envelopToSend = null;
  +
  +		
  +			//Crate amessage using the reqSOAPEnvelop string parameter.
  +			Message msg = new Message(reqSOAPEnvelop);
  +
  +			//Get the envelop using the message.
  +			SOAPEnvelope requestEnvelop = msg.getSOAPEnvelope();
  +			envelopToSend = new SOAPEnvelope();
  +			envelopToSend.setSchemaVersion(requestEnvelop.getSchemaVersion());
  +			envelopToSend.setSoapConstants(requestEnvelop.getSOAPConstants());
  +			envelopToSend.setBody(
  +				(org.apache.axis.message.SOAPBody) requestEnvelop.getBody());
  +			envelopToSend.addNamespaceDeclaration(
  +				"wsrm",
  +				"http://schemas.xmlsoap.org/ws/2003/03/rm");
  +			envelopToSend.addNamespaceDeclaration(
  +				"wsa",
  +				"http://schemas.xmlsoap.org/ws/2003/03/addressing");
  +			envelopToSend.addNamespaceDeclaration(
  +				"wsu",
  +				"http://schemas.xmlsoap.org/ws/2003/07/utility");
  +
  +			//New envelop to create the SOAP envelop to send. Why use of two envelop is not clear.
  +			//adding the name spaces to the env
  +			// now get the sequence element
  +			Sequence seqElement = new Sequence();
  +			seqElement.setIdentifier(identifier);
  +
  +			MessageNumber msgNumber = new MessageNumber();
  +			msgNumber.setMessageNumber(rmMessage.getMessageNumber());
  +
  +			if (isLastMessage.equals("true")) {
  +				LastMessage lastMessage = new LastMessage();
  +				seqElement.setLastMessage(lastMessage);
  +			}
  +
  +			seqElement.setMessageNumber(msgNumber);
  +
  +			//add the sequence element to the envelop to send
  +			seqElement.toSoapEnvelop(envelopToSend);
  +
  +			//set the action
  +			URI actionURI = new URI(strAction);
  +			Action action = new Action(actionURI);
  +			action.toSOAPHeaderElement(envelopToSend);
  +
  +			//Set from address.
  +
  +			URI fromAddressURI = new URI(toClientServiceURL);
  +			Address fromAddress = new Address(fromAddressURI);
  +
  +			//Set the from header.
  +			From from = new From(fromAddress);
  +			from.toSOAPHeaderElement(envelopToSend);
  +
  +			rmMessage.getMessageID().toSOAPHeaderElement(envelopToSend);
  +
  +			if (!strReplyTo.equals("")) {
  +				URI relyToAddressURI = new URI(strReplyTo);
  +				Address replyToAddress = new Address(relyToAddressURI);
  +				ReplyTo replyTo = new ReplyTo(replyToAddress);
  +				replyTo.toSOAPHeaderElement(envelopToSend);
  +			}
  +
  +			//Set the to address.
  +
  +			URI toAddress = new To(destinationURL);
  +			To to = new To(toAddress);
  +			to.toSOAPHeaderElement(envelopToSend);
  +
  +			//now store this new message in the rmMessage
  +			//so that it can be used for retrasmission
  +
  +		
  +		return envelopToSend;
  +	}
  +
  +	/**
  +	 * Method getSimpleEnvelope
  +	 * 
  +	 * @param action     
  +	 * @param messageID         
  +	 * 
  +	 * @return SOAPEnvelope
  +	 */
  +
  +	private SOAPEnvelope getSimpleEnvelope(
  +		String action,
  +		MessageID messageID) throws Exception {
  +		SOAPEnvelope envelopToSend = new SOAPEnvelope();
  +	
  +
  +			envelopToSend.addNamespaceDeclaration(
  +				"wsrm",
  +				"http://schemas.xmlsoap.org/ws/2003/03/rm");
  +			envelopToSend.addNamespaceDeclaration(
  +				"wsa",
  +				"http://schemas.xmlsoap.org/ws/2003/03/addressing");
  +			envelopToSend.addNamespaceDeclaration(
  +				"wsu",
  +				"http://schemas.xmlsoap.org/ws/2003/07/utility");
  +
  +			URI actionURI = new URI(action);
  +			Action tempAction = new Action(actionURI);
  +			tempAction.toSOAPHeaderElement(envelopToSend);
  +
  +			messageID.toSOAPHeaderElement(envelopToSend);
  +
  +	
  +		return envelopToSend;
  +	}
  +
   }