1 17 18 package org.apache.sandesha.ws.rm; 19 20 import org.apache.axis.AxisFault; 21 import org.apache.axis.message.SOAPBodyElement; 22 import org.apache.axis.message.SOAPEnvelope; 23 import org.apache.axis.message.SOAPHeaderElement; 24 import org.apache.sandesha.Constants; 25 26 import java.util.Iterator ; 27 28 35 public class RMHeaders { 36 37 40 private CreateSequence createSequence = null; 41 42 45 private CreateSequenceResponse createSequenceResponse = null; 46 47 50 private AckRequested ackRequest = null; 51 52 55 private SequenceAcknowledgement sequenceAcknowledgement = null; 56 57 60 private Sequence sequence = null; 61 62 65 private TerminateSequence terminateSequence = null; 66 67 68 75 public SOAPEnvelope toSoapEnvelop(SOAPEnvelope envelope) throws Exception { 76 77 SOAPEnvelope env = envelope; 78 79 if (createSequence != null) { 80 createSequence.toSoapEnvelop(env); 81 } 82 if (createSequenceResponse != null) { 83 createSequenceResponse.toSoapEnvelop(env); 84 } 85 if (sequenceAcknowledgement != null) { 86 sequenceAcknowledgement.toSoapEnvelop(env); 87 } 88 if (sequence != null) { 89 sequence.toSoapEnvelop(env); 90 } 91 if (ackRequest != null) { 92 ackRequest.toSoapEnvelop(env); 93 } 94 if (terminateSequence != null) { 95 terminateSequence.toSoapEnvelop(env); 96 } 97 98 return env; 99 } 100 101 108 public RMHeaders fromSOAPEnvelope(SOAPEnvelope env) throws Exception , AxisFault { 109 110 if (env != null) { 111 Iterator iterator = env.getHeaders().iterator(); 112 SOAPHeaderElement headerElement; 113 114 while (iterator.hasNext()) { 115 headerElement = (SOAPHeaderElement) iterator.next(); 116 117 if (headerElement.getName().equals(Constants.WSRM.SEQUENCE)) { 118 sequence = new Sequence(); 119 headerElement.setProcessed(true); 120 headerElement.setMustUnderstand(false); 121 sequence.fromSOAPEnveploe(headerElement); 122 } 123 124 if (headerElement.getName().equals(Constants.WSRM.SEQUENCE_ACK)) { 125 sequenceAcknowledgement = new SequenceAcknowledgement(); 126 headerElement.setProcessed(true); 127 headerElement.setMustUnderstand(false); 128 sequenceAcknowledgement.fromSOAPEnveploe(headerElement); 129 } 130 131 if (headerElement.getName().equals(Constants.WSRM.ACK_REQUESTED)) { 132 ackRequest = new AckRequested(); 133 headerElement.setProcessed(true); 134 headerElement.setMustUnderstand(false); 135 ackRequest.fromSOAPEnveploe(headerElement); 136 } 137 } 138 139 iterator = (Iterator ) env.getBody().getChildElements(); 140 141 SOAPBodyElement bodyElement; 142 143 while (iterator.hasNext()) { 144 bodyElement = (SOAPBodyElement) iterator.next(); 145 146 if (bodyElement.getName().equals(Constants.WSRM.CREATE_SEQUENCE)) { 147 createSequence = new CreateSequence(); 148 149 createSequence.fromSOAPEnveploe(bodyElement); 150 } 151 152 if (bodyElement.getName().equals(Constants.WSRM.CREATE_SEQUENCE_RESPONSE)) { 153 createSequenceResponse = new CreateSequenceResponse(); 154 155 createSequenceResponse.fromSOAPEnveploe(bodyElement); 156 } 157 158 if (bodyElement.getName().equals(Constants.WSRM.TERMINATE_DEQUENCE)) { 159 terminateSequence = new TerminateSequence(); 160 161 terminateSequence.fromSOAPEnveploe(bodyElement); 162 } 163 } 164 } 165 166 return this; 167 } 168 169 174 public CreateSequenceResponse getCreateSequenceResponse() { 175 return createSequenceResponse; 176 } 177 178 183 public Sequence getSequence() { 184 return sequence; 185 } 186 187 192 public SequenceAcknowledgement getSequenceAcknowledgement() { 193 return sequenceAcknowledgement; 194 } 195 196 201 public TerminateSequence getTerminateSequence() { 202 return terminateSequence; 203 } 204 205 210 public void setCreateSequence(CreateSequence sequence) { 211 createSequence = sequence; 212 } 213 214 219 public void setCreateSequenceResponse(CreateSequenceResponse response) { 220 createSequenceResponse = response; 221 } 222 223 228 public void setSequence(Sequence sequence) { 229 this.sequence = sequence; 230 } 231 232 237 public void setSequenceAcknowledgement(SequenceAcknowledgement acknowledgement) { 238 sequenceAcknowledgement = acknowledgement; 239 } 240 241 246 public void c(TerminateSequence sequence) { 247 terminateSequence = sequence; 248 } 249 250 255 public void setAckRequest(AckRequested requested) { 256 ackRequest = requested; 257 } 258 259 264 public AckRequested getAckRequest() { 265 return ackRequest; 266 } 267 268 273 public CreateSequence getCreateSequence() { 274 return createSequence; 275 } 276 277 public static void removeHeaders(SOAPEnvelope env) throws AxisFault { 278 if (env != null) { 279 Iterator iterator = env.getHeaders().iterator(); 280 SOAPHeaderElement headerElement; 281 282 while (iterator.hasNext()) { 283 headerElement = (SOAPHeaderElement) iterator.next(); 284 285 if (headerElement.getName().equals(Constants.WSRM.SEQUENCE)) { 286 headerElement.detachNode(); 287 } 288 if (headerElement.getName().equals(Constants.WSRM.SEQUENCE_ACK)) { 289 headerElement.detachNode(); 290 } 291 if (headerElement.getName().equals(Constants.WSRM.ACK_REQUESTED)) { 292 headerElement.detachNode(); 293 } 294 } 295 } 296 } 297 } | Popular Tags |