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/09/13 13:27:38 UTC

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

jaliya      2004/09/13 04:27:38

  Modified:    sandesha/src/org/apache/sandesha/client
                        ClientMessageController.java RMClientReference.java
                        RMClientService.java
  Log:
  Formatted code
  
  Revision  Changes    Path
  1.10      +48 -50    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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ClientMessageController.java	7 May 2004 17:39:38 -0000	1.9
  +++ ClientMessageController.java	13 Sep 2004 11:27:37 -0000	1.10
  @@ -17,133 +17,132 @@
   
   package org.apache.sandesha.client;
   
  +import java.util.HashMap;
  +import java.util.Map;
  +
   import org.apache.axis.message.addressing.MessageID;
   import org.apache.sandesha.RMMessage;
   import org.apache.sandesha.RMSequence;
   import org.apache.sandesha.ws.utility.Identifier;
   
  -import java.util.HashMap;
  -import java.util.Map;
  -
  -
   /**
  - * @author
  - * Amila Navarathna<br>
  - * Jaliya Ekanayaka<br>
  - * Sudar Nimalan<br>
  - * (Apache Sandesha Project)
  - *
  + * @author Amila Navarathna <br>
  + *         Jaliya Ekanayaka <br>
  + *         Sudar Nimalan <br>
  + *         (Apache Sandesha Project)
  + *  
    */
   public class ClientMessageController {
       /**
        * Field instance
        */
       private static ClientMessageController instance;
  +
       /**
        * Field messageMap
        */
       private Map messageMap;
  +
       /**
        * Field sequenceMap
        */
       private Map sequenceMap;
  +
       /**
        * Field seqAck
        */
  - 
  +
       private Identifier sequenceIdentifier;
  -    
  +
       /**
        * Constructor ClientMessageController
  -     */  
  +     */
       private ClientMessageController() {
           sequenceMap = new HashMap();
           messageMap = new HashMap();
       }
  -    
  +
       /**
        * Method getInstance
        * 
        * @return ClientMessageController
        */
  -     public static ClientMessageController getInstance() {
  -       
  +    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>
  +     * 
  +     * 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) {
  +        RMMessage rmMessage = (RMMessage) messageMap.get(messageID.toString());
  +        if (rmMessage != null) {
               return rmMessage;
           } else {
               return null;
           }
       }
   
  -
       /**
        * Method storeSequence
        * 
        * 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
  -     *
  +     * consists of one or more message objects. The sequences are stored as the
  +     * sequenceIdentifier as a key
  +     * 
        * @param sequence
  -     *
        * 
  +     *  
        */
       public void storeSequence(RMSequence sequence) {
  -      
  +
           sequenceMap.put(sequence.getSequenceIdentifier().toString(), sequence);
       }
  -    
  +
       /**
        * Method storeMessage
        * 
  -     * stores a message object in the map. 
  -     * The message are stored as the message id as a key
  -     *
  +     * stores a message object in the map. The message are stored as the message
  +     * id as a key
  +     * 
        * @param message
  -     *
        * 
  +     *  
        */
   
       public void storeMessage(RMMessage message) {
           messageMap.put(message.getMessageID().toString(), message);
       }
   
  -
       /**
        * Method retrieveIfSequenceExists
  -     *
  -     * returns a RMSequence if a sequence for the identifier exists.
  -     * else return a null value
  -     * <b>developer must handle the null value returned</b>
  +     * 
  +     * 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
        * 
        * @return RMSequence
  -     *
        * 
  +     *  
        */
       public RMSequence retrieveIfSequenceExists(Identifier identifier) {
  -        RMSequence rmSequence = (RMSequence)sequenceMap.get(identifier.getIdentifier().toString());
  +        RMSequence rmSequence = (RMSequence) sequenceMap.get(identifier
  +                .getIdentifier().toString());
           if (rmSequence != null) {
               return rmSequence;
           } else {
  @@ -151,23 +150,22 @@
           }
       }
   
  -
  -    
       /**
        * Method removeIfSequenceExists
        * 
  -     * Search for a sequence and if it exists(means it is in the map),
  -     * remove it from the map
  +     * 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
        * 
  @@ -180,11 +178,11 @@
       /**
        * Method setSequenceIdentifier
        * 
  -     * @param  identifier
  -     * 
  +     * @param identifier
  +     *  
        */
       public void setSequenceIdentifier(Identifier identifier) {
           sequenceIdentifier = identifier;
       }
   
  -}
  +}
  \ No newline at end of file
  
  
  
  1.2       +6 -7      ws-fx/sandesha/src/org/apache/sandesha/client/RMClientReference.java
  
  Index: RMClientReference.java
  ===================================================================
  RCS file: /home/cvs/ws-fx/sandesha/src/org/apache/sandesha/client/RMClientReference.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RMClientReference.java	7 May 2004 17:39:38 -0000	1.1
  +++ RMClientReference.java	13 Sep 2004 11:27:37 -0000	1.2
  @@ -18,14 +18,13 @@
   package org.apache.sandesha.client;
   
   /**
  - * @author
  - * Amila Navarathna<br>
  - * Jaliya Ekanayaka<br>
  - * Sudar Nimalan<br>
  - * (Apache Sandesha Project)
  - *
  + * @author Amila Navarathna <br>
  + *         Jaliya Ekanayaka <br>
  + *         Sudar Nimalan <br>
  + *         (Apache Sandesha Project)
  + *  
    */
   
   public class RMClientReference {
   
  -}
  +}
  \ No newline at end of file
  
  
  
  1.14      +169 -219  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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- RMClientService.java	11 May 2004 04:42:37 -0000	1.13
  +++ RMClientService.java	13 Sep 2004 11:27:38 -0000	1.14
  @@ -16,6 +16,9 @@
    */
   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;
  @@ -43,16 +46,12 @@
   import org.apache.sandesha.ws.rm.Sequence;
   import org.apache.sandesha.ws.utility.Identifier;
   
  -import javax.xml.rpc.ServiceException;
  -import javax.xml.soap.SOAPException;
  -
   /**
  - * @author
  - * Amila Navarathna<br>
  - * Jaliya Ekanayaka<br>
  - * Sudar Nimalan<br>
  - * (Apache Sandesha Project)
  - *
  + * @author Amila Navarathna <br>
  + *         Jaliya Ekanayaka <br>
  + *         Sudar Nimalan <br>
  + *         (Apache Sandesha Project)
  + *  
    */
   public class RMClientService {
   
  @@ -64,55 +63,46 @@
       /**
        * Method clientMethod
        * 
  -     * @param reqSOAPEnvelope     
  -     * @param sequenceID         
  -     * @param destinationURL     
  -     * @param sourceURL 
  -     * @param isSynchronous           
  -     * @param isLastMessage 
  -     * @param isResponseExpected 
  +     * @param reqSOAPEnvelope
  +     * @param sequenceID
  +     * @param destinationURL
  +     * @param sourceURL
  +     * @param isSynchronous
  +     * @param isLastMessage
  +     * @param isResponseExpected
        * @param action
        * @param replyTo
        * 
        * @return String
        */
  -    public String clientMethod(
  -        String reqSOAPEnvelope,
  -        String sequenceID,
  -        String destinationURL,
  -        String sourceURL,
  -        String isSynchronous,
  -        String isLastMessage,
  -        String isResponseExpected,
  -        String action,
  -        String replyTo)
  -        throws SOAPException, ServiceException, AxisFault {
  +    public String clientMethod(String reqSOAPEnvelope, 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();
  +        ClientMessageController clientMessageController = ClientMessageController
  +                .getInstance();
           UUIDGen uuidGen = UUIDGenFactory.getUUIDGen();
   
           try {
   
               if (sequenceID.equals("")) {
  -                if ((clientMessageController.getSequenceIdentifier()
  -                    == null)) {
  +                if ((clientMessageController.getSequenceIdentifier() == null)) {
   
                       URI messageIDURIForCreateSequence;
  -                    messageIDURIForCreateSequence =
  -                        new URI("uuid:" + uuidGen.nextUUID());
  -                    MessageID messageIDForCreateSequence =
  -                        new MessageID(messageIDURIForCreateSequence);
  -                    SOAPEnvelope envelopToSend =
  -                        getSimpleEnvelope(
  +                    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);
  +                    Address anonymousAddress = new Address(
  +                            Constants.ANONYMOUS_URI);
  +                    ReplyTo replyToForCreateSequence = new ReplyTo(
  +                            anonymousAddress);
                       replyToForCreateSequence.toSOAPHeaderElement(envelopToSend);
   
                       To toForCreateSequence = new To(destinationURL);
  @@ -124,26 +114,25 @@
                       Call call = new Call(destinationURL);
                       call.setRequestMessage(new Message(envelopToSend));
                       call.invoke();
  -                    SOAPEnvelope responseEnvelope =
  -                        call.getResponseMessage().getSOAPEnvelope();
  +                    SOAPEnvelope responseEnvelope = call.getResponseMessage()
  +                            .getSOAPEnvelope();
                       RMHeaders rmHeaders = new RMHeaders();
                       rmHeaders.fromSOAPEnvelope(responseEnvelope);
  -                    Identifier tempIdentifier =
  -                        rmHeaders.getCreateSequenceResponse().getIdentifier();
  +                    Identifier tempIdentifier = rmHeaders
  +                            .getCreateSequenceResponse().getIdentifier();
   
                       if (tempIdentifier != null) {
                           sequenceID = tempIdentifier.getIdentifier();
  -                        clientMessageController.setSequenceIdentifier(
  -                            tempIdentifier);
  +                        clientMessageController
  +                                .setSequenceIdentifier(tempIdentifier);
                       } else {
  -                        throw new AxisFault("No Response for Create Sequence Request..");
  +                        throw new AxisFault(
  +                                "No Response for Create Sequence Request..");
                       }
   
                   } else {
  -                    sequenceID =
  -                        clientMessageController
  -                            .getSequenceIdentifier()
  -                            .getIdentifier();
  +                    sequenceID = clientMessageController
  +                            .getSequenceIdentifier().getIdentifier();
                   }
               }
   
  @@ -163,8 +152,8 @@
               MessageID messageID = new MessageID(messageIDURI);
               rmMessage.setMessageID(messageID);
   
  -            RMSequence sequence =
  -                clientMessageController.retrieveIfSequenceExists(identifier);
  +            RMSequence sequence = clientMessageController
  +                    .retrieveIfSequenceExists(identifier);
   
               if (sequence == null) { //means there is no sequence
                   sequence = new RMSequence(identifier);
  @@ -182,49 +171,35 @@
   
               if (isSynchronous.equals("true")) {
                   //TODO: normal invocation. but for future...
  -                SOAPEnvelope syncReqEnv =
  -                    getInitialMessageWithRMHeaders(
  -                        reqSOAPEnvelope,
  -                        rmMessage,
  -                        identifier,
  -                        destinationURL,
  -                        Constants.ANONYMOUS_URI,
  -                        isLastMessage,
  -                        isResponseExpected,
  -                        action,
  -                        replyTo);
  +                SOAPEnvelope syncReqEnv = getInitialMessageWithRMHeaders(
  +                        reqSOAPEnvelope, 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();*/
  -                
  -				Call call=new Call(destinationURL);
  -				Message msg=new Message(syncReqEnv);
  -				call.setRequestMessage(msg);
  -				call.invoke();
  -                
  -                
  +                /*
  +                 * Service service = new Service(); Call call = (Call)
  +                 * service.createCall();
  +                 * call.setTargetEndpointAddress(destinationURL);
  +                 * call.invoke(syncReqEnv); stringReturn =
  +                 * call.getResponseMessage().getSOAPPartAsString();
  +                 */
  +
  +                Call call = new Call(destinationURL);
  +                Message msg = new Message(syncReqEnv);
  +                call.setRequestMessage(msg);
  +                call.invoke();
   
               } else {
   
                   if (isResponseExpected.equals("true")) {
                       //Response Expected
  -                    SOAPEnvelope envelopToSend =
  -                        getInitialMessageWithRMHeaders(
  -                            reqSOAPEnvelope,
  -                            rmMessage,
  -                            identifier,
  -                            destinationURL,
  -                            sourceURL,
  -                            isLastMessage,
  -                            isResponseExpected,
  -                            action,
  -                            replyTo);
  +                    SOAPEnvelope envelopToSend = getInitialMessageWithRMHeaders(
  +                            reqSOAPEnvelope, rmMessage, identifier,
  +                            destinationURL, sourceURL, isLastMessage,
  +                            isResponseExpected, action, replyTo);
   
                       Message newMessage = new Message(envelopToSend);
                       rmMessage.setRequestMessage(newMessage);
  @@ -233,12 +208,11 @@
                       Service service = new Service();
                       Call call = (Call) service.createCall();
                       call.setTargetEndpointAddress(destinationURL);
  -                    try{
  -						call.invoke(envelopToSend);
  -                    }catch(Exception e){
  +                    try {
  +                        call.invoke(envelopToSend);
  +                    } catch (Exception e) {
                           log.error(e);
                       }
  -                    
   
                       boolean gotResponse = false;
                       int count = 0;
  @@ -246,8 +220,8 @@
                       Message tempMessage = rmMessage.getRequestMessage();
                       AckRequested ackRequested = new AckRequested();
                       ackRequested.setIdentifier(rmMessage.getIdentifier());
  -                    SOAPEnvelope retransmissionEnvelope =
  -                        tempMessage.getSOAPEnvelope();
  +                    SOAPEnvelope retransmissionEnvelope = tempMessage
  +                            .getSOAPEnvelope();
   
                       ackRequested.toSoapEnvelop(retransmissionEnvelope);
   
  @@ -257,13 +231,11 @@
                           Thread.sleep(2000);
   
                           if (new Boolean(rmMessage.getIsResponseExpected())
  -                            .booleanValue()) {
  +                                .booleanValue()) {
   
                               if (rmMessage.getResponseMessage() != null) {
                                   gotResponse = true;
  -                                stringReturn =
  -                                    rmMessage
  -                                        .getResponseMessage()
  +                                stringReturn = rmMessage.getResponseMessage()
                                           .getSOAPPartAsString();
                                   break;
                               }
  @@ -273,19 +245,18 @@
   
                           if (!rmMessage.isAcknowledged()) {
   
  -                            Message retransmissionMessage =
  -                                new Message(retransmissionEnvelope);
  +                            Message retransmissionMessage = new Message(
  +                                    retransmissionEnvelope);
                               Service retransmissionService = new Service();
  -                            Call retransmissionCall =
  -                                (Call) service.createCall();
  -                            retransmissionCall.setTargetEndpointAddress(
  -                                destinationURL);
  -                                try{
  -									retransmissionCall.invoke(envelopToSend);
  -                                }catch(Exception e){
  -                                	log.error(e);                                	                                	
  -                                }
  -                            
  +                            Call retransmissionCall = (Call) service
  +                                    .createCall();
  +                            retransmissionCall
  +                                    .setTargetEndpointAddress(destinationURL);
  +                            try {
  +                                retransmissionCall.invoke(envelopToSend);
  +                            } catch (Exception e) {
  +                                log.error(e);
  +                            }
   
                           }
   
  @@ -297,17 +268,10 @@
   
                   } else {
                       //No Response
  -                    SOAPEnvelope envelopToSend =
  -                        getInitialMessageWithRMHeaders(
  -                            reqSOAPEnvelope,
  -                            rmMessage,
  -                            identifier,
  -                            destinationURL,
  -                            sourceURL,
  -                            isLastMessage,
  -                            isResponseExpected,
  -                            action,
  -                            replyTo);
  +                    SOAPEnvelope envelopToSend = getInitialMessageWithRMHeaders(
  +                            reqSOAPEnvelope, rmMessage, identifier,
  +                            destinationURL, sourceURL, isLastMessage,
  +                            isResponseExpected, action, replyTo);
   
                       Message newMessage = new Message(envelopToSend);
                       rmMessage.setRequestMessage(newMessage);
  @@ -321,8 +285,8 @@
                       Message tempMessage = rmMessage.getRequestMessage();
                       AckRequested ackRequested = new AckRequested();
                       ackRequested.setIdentifier(rmMessage.getIdentifier());
  -                    SOAPEnvelope retransmissionEnvelope =
  -                        tempMessage.getSOAPEnvelope();
  +                    SOAPEnvelope retransmissionEnvelope = tempMessage
  +                            .getSOAPEnvelope();
                       ackRequested.toSoapEnvelop(retransmissionEnvelope);
   
                       while (count < Constants.MAXIMUM_RETRANSMISSION_COUNT) {
  @@ -330,13 +294,13 @@
                           //Wait for RETRANSMISSION_INTERVAL
                           Thread.sleep(Constants.RETRANSMISSION_INTERVAL);
                           if (!rmMessage.isAcknowledged()) {
  -                            Message retransmissionMessage =
  -                                new Message(retransmissionEnvelope);
  +                            Message retransmissionMessage = new Message(
  +                                    retransmissionEnvelope);
                               Service retransmissionService = new Service();
  -                            Call retransmissionCall =
  -                                (Call) service.createCall();
  -                            retransmissionCall.setTargetEndpointAddress(
  -                                destinationURL);
  +                            Call retransmissionCall = (Call) service
  +                                    .createCall();
  +                            retransmissionCall
  +                                    .setTargetEndpointAddress(destinationURL);
                               retransmissionCall.invoke(envelopToSend);
   
                           } else {
  @@ -373,132 +337,118 @@
        * @param isResponseExpected
        * @param strAction
        * @param strReplyTo
  -     *     
  +     * 
        * @return SOAPEnvelope
        */
   
  -    private SOAPEnvelope getInitialMessageWithRMHeaders(
  -        String reqSOAPEnvelope,
  -        RMMessage rmMessage,
  -        Identifier identifier,
  -        String destinationURL,
  -        String toClientServiceURL,
  -        String isLastMessage,
  -        String isResponseExpected,
  -        String strAction,
  -        String strReplyTo) throws Exception {
  +    private SOAPEnvelope getInitialMessageWithRMHeaders(String reqSOAPEnvelope,
  +            RMMessage rmMessage, Identifier identifier, String destinationURL,
  +            String toClientServiceURL, String isLastMessage,
  +            String isResponseExpected, String strAction, String strReplyTo)
  +            throws Exception {
   
           SOAPEnvelope envelopToSend = null;
   
  -        
  -            //Crate a message using the reqSOAPEnvelope string parameter.
  -            Message msg = new Message(reqSOAPEnvelope);
  -
  -            //Get the envelope using the message.
  -            SOAPEnvelope requestEnvelope = msg.getSOAPEnvelope();
  -            envelopToSend = new SOAPEnvelope();
  -            envelopToSend.setSchemaVersion(requestEnvelope.getSchemaVersion());
  -            envelopToSend.setSoapConstants(requestEnvelope.getSOAPConstants());
  -            envelopToSend.setBody(
  -                (org.apache.axis.message.SOAPBody) requestEnvelope.getBody());
  -            envelopToSend.addNamespaceDeclaration(
  -                Constants.NS_PREFIX_RM,
  +        //Crate a message using the reqSOAPEnvelope string parameter.
  +        Message msg = new Message(reqSOAPEnvelope);
  +
  +        //Get the envelope using the message.
  +        SOAPEnvelope requestEnvelope = msg.getSOAPEnvelope();
  +        envelopToSend = new SOAPEnvelope();
  +        envelopToSend.setSchemaVersion(requestEnvelope.getSchemaVersion());
  +        envelopToSend.setSoapConstants(requestEnvelope.getSOAPConstants());
  +        envelopToSend
  +                .setBody((org.apache.axis.message.SOAPBody) requestEnvelope
  +                        .getBody());
  +        envelopToSend.addNamespaceDeclaration(Constants.NS_PREFIX_RM,
                   Constants.NS_URI_RM);
  -            envelopToSend.addNamespaceDeclaration(
  -                Constants.WSA_PREFIX,
  +        envelopToSend.addNamespaceDeclaration(Constants.WSA_PREFIX,
                   Constants.WSA_NS);
  -            envelopToSend.addNamespaceDeclaration(
  -                Constants.WSU_PREFIX,
  +        envelopToSend.addNamespaceDeclaration(Constants.WSU_PREFIX,
                   Constants.WSU_NS);
   
  -            //New envelope to create the SOAP envelope to send. Why use of two envelope 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);
  -            }
  +        //New envelope to create the SOAP envelope to send. Why use of two
  +        // envelope 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);
  +        seqElement.setMessageNumber(msgNumber);
   
  -            //add the sequence element to the envelope to send
  -            seqElement.toSoapEnvelop(envelopToSend);
  +        //add the sequence element to the envelope to send
  +        seqElement.toSoapEnvelop(envelopToSend);
   
  -            //set the action
  -            URI actionURI = new URI(strAction);
  -            Action action = new Action(actionURI);
  -            action.toSOAPHeaderElement(envelopToSend);
  +        //set the action
  +        URI actionURI = new URI(strAction);
  +        Action action = new Action(actionURI);
  +        action.toSOAPHeaderElement(envelopToSend);
   
  -            //Set from address.
  +        //Set from address.
   
  -            URI fromAddressURI = new URI(toClientServiceURL);
  -            Address fromAddress = new Address(fromAddressURI);
  +        URI fromAddressURI = new URI(toClientServiceURL);
  +        Address fromAddress = new Address(fromAddressURI);
   
  -            //Set the from header.
  -            From from = new From(fromAddress);
  -            from.toSOAPHeaderElement(envelopToSend);
  +        //Set the from header.
  +        From from = new From(fromAddress);
  +        from.toSOAPHeaderElement(envelopToSend);
   
  -            rmMessage.getMessageID().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);
  -            }
  +        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.
  +        //Set the to address.
   
  -            URI toAddress = new To(destinationURL);
  -            To to = new To(toAddress);
  -            to.toSOAPHeaderElement(envelopToSend);
  +        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
  +        //now store this new message in the rmMessage
  +        //so that it can be used for retrasmission
   
  -        
           return envelopToSend;
       }
   
       /**
        * Method getSimpleEnvelope
        * 
  -     * @param action     
  -     * @param messageID         
  +     * @param action
  +     * @param messageID
        * 
        * @return SOAPEnvelope
        */
   
  -    private SOAPEnvelope getSimpleEnvelope(
  -        String action,
  -        MessageID messageID) throws Exception {
  +    private SOAPEnvelope getSimpleEnvelope(String action, MessageID messageID)
  +            throws Exception {
           SOAPEnvelope envelopToSend = new SOAPEnvelope();
  -    
   
  -            envelopToSend.addNamespaceDeclaration(
  -                    Constants.NS_PREFIX_RM,
  -                    Constants.NS_URI_RM);
  -            envelopToSend.addNamespaceDeclaration(
  -                    Constants.WSA_PREFIX,
  -                    Constants.WSA_NS);
  -            envelopToSend.addNamespaceDeclaration(
  -                    Constants.WSU_PREFIX,
  -                    Constants.WSU_NS);
  -
  -            URI actionURI = new URI(action);
  -            Action tempAction = new Action(actionURI);
  -            tempAction.toSOAPHeaderElement(envelopToSend);
  +        envelopToSend.addNamespaceDeclaration(Constants.NS_PREFIX_RM,
  +                Constants.NS_URI_RM);
  +        envelopToSend.addNamespaceDeclaration(Constants.WSA_PREFIX,
  +                Constants.WSA_NS);
  +        envelopToSend.addNamespaceDeclaration(Constants.WSU_PREFIX,
  +                Constants.WSU_NS);
  +
  +        URI actionURI = new URI(action);
  +        Action tempAction = new Action(actionURI);
  +        tempAction.toSOAPHeaderElement(envelopToSend);
   
  -            messageID.toSOAPHeaderElement(envelopToSend);
  +        messageID.toSOAPHeaderElement(envelopToSend);
   
  -    
           return envelopToSend;
       }
   
  -}
  +}
  \ No newline at end of file