1 17 18 package org.apache.sandesha.ws.rm; 19 20 import org.apache.axis.message.MessageElement; 21 import org.apache.axis.message.SOAPBodyElement; 22 import org.apache.axis.message.SOAPEnvelope; 23 import org.apache.sandesha.Constants; 24 25 import javax.xml.soap.Name ; 26 import javax.xml.soap.SOAPException ; 27 import java.util.Iterator ; 28 29 36 public class CreateSequence implements IRmElement { 37 38 41 private MessageElement createSequence; 42 43 private SequenceOffer offer; 44 45 private AcksTo acksTo; 46 47 50 public CreateSequence() { 51 createSequence = new MessageElement(); 52 createSequence.setName(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.CREATE_SEQUENCE); 53 } 54 55 56 61 public MessageElement getSoapElement() throws SOAPException { 62 createSequence.addChildElement(acksTo.getSoapElement()); 63 createSequence.addChildElement(offer.getSoapElement()); 64 return createSequence; 65 } 66 67 74 public SOAPEnvelope toSoapEnvelop(SOAPEnvelope envelope) throws SOAPException { 75 76 SOAPEnvelope env = envelope; 77 if (env.getBody() == null) { 78 env.addBody(); 79 } 80 81 Name name = env.createName("", Constants.WSRM.NS_PREFIX_RM, Constants.WSRM.NS_URI_RM); 82 SOAPBodyElement bodyElement = (SOAPBodyElement) env.getBody().addBodyElement(name); 83 84 bodyElement.setName(Constants.WSRM.CREATE_SEQUENCE); 85 86 if (acksTo != null) 87 acksTo.toSOAPEnvelope(bodyElement); 88 if (offer != null) 89 offer.toSOAPEnvelope(bodyElement); 90 91 return env; 92 } 93 94 100 public CreateSequence fromSOAPEnveploe(SOAPBodyElement bodyElement) throws Exception { 101 102 Iterator iterator = bodyElement.getChildElements(); 103 MessageElement childElement; 104 while (iterator.hasNext()) { 105 106 childElement = (MessageElement) iterator.next(); 109 110 if (childElement.getName().equals(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.ACKS_TO)) { 111 acksTo = new AcksTo(); 112 acksTo.fromSOAPEnvelope(childElement); 113 } else if (childElement.getName().equals(Constants.WSRM.ACKS_TO)) { 114 acksTo = new AcksTo(); 115 acksTo.fromSOAPEnvelope(childElement); 116 } else if (childElement.getName().equals(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.SEQUENCE_OFFER)) { 117 offer = new SequenceOffer(); 118 offer.fromSOAPEnvelope(childElement); 119 } else if (childElement.getName().equals(Constants.WSRM.SEQUENCE_OFFER)) { 120 offer = new SequenceOffer(); 121 offer.fromSOAPEnvelope(childElement); 122 } 123 124 } 125 return this; 126 } 127 128 133 public void addChildElement(MessageElement element) { 134 } 135 136 137 public SequenceOffer getOffer() { 138 return offer; 139 } 140 141 142 public void setOffer(SequenceOffer offer) { 143 this.offer = offer; 144 } 145 146 public AcksTo getAcksTo() { 147 return acksTo; 148 } 149 150 public void setAcksTo(AcksTo acksTo) { 151 this.acksTo = acksTo; 152 } 153 } | Popular Tags |