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 CreateSequenceResponse implements IRmElement { 37 38 41 private MessageElement createSequenceResponse; 42 43 46 private Identifier identifier; 47 48 private Accept accept; 49 50 53 public CreateSequenceResponse() { 54 createSequenceResponse = new MessageElement(); 55 createSequenceResponse.setName(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.CREATE_SEQUENCE_RESPONSE); 56 } 57 58 63 public MessageElement getSoapElement() { 64 return createSequenceResponse; 65 } 66 67 74 public SOAPEnvelope toSoapEnvelop(SOAPEnvelope envelope) 75 throws SOAPException { 76 77 SOAPEnvelope env = envelope; 78 79 if (env.getBody() == null) { 80 env.addBody(); 81 } 82 Name name = env.createName("", Constants.WSRM.NS_PREFIX_RM, Constants.WSRM.NS_URI_RM); 83 SOAPBodyElement bodyElement = (SOAPBodyElement) env.getBody().addBodyElement(name); 84 bodyElement.setName(Constants.WSRM.CREATE_SEQUENCE_RESPONSE); 85 if (identifier != null) { 86 identifier.toSOAPEnvelope(bodyElement); 87 } 88 if (accept != null) 89 accept.toSOAPEnvelope(bodyElement); 90 return env; 91 } 92 93 99 public CreateSequenceResponse fromSOAPEnveploe(SOAPBodyElement bodyElement) throws SOAPException { 100 101 Iterator iterator = bodyElement.getChildElements(); 102 MessageElement childElement; 103 104 while (iterator.hasNext()) { 105 childElement = (MessageElement) iterator.next(); 106 107 if (childElement.getName().equals(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.IDENTIFIER)) { 108 identifier = new Identifier(); 109 identifier.fromSOAPEnvelope(childElement); 110 } 111 112 if (childElement.getName().equals(Constants.WSRM.IDENTIFIER)) { 113 identifier = new Identifier(); 114 identifier.fromSOAPEnvelope(childElement); 115 } 116 117 if (childElement.getName().equals(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.ACCEPT)) { 118 accept = new Accept(); 119 accept.fromSOAPEnvelope(childElement); 120 } 121 122 if (childElement.getName().equals(Constants.WSRM.ACCEPT)) { 123 accept = new Accept(); 124 accept.fromSOAPEnvelope(childElement); 125 } 126 } 127 128 return this; 129 } 130 131 137 public void addChildElement(MessageElement element) throws SOAPException { 138 createSequenceResponse.addChildElement(element); 139 } 140 141 144 public Identifier getIdentifier() { 145 return identifier; 146 } 147 148 public Accept getAccept() { 149 return accept; 150 } 151 152 public void setAccept(Accept accept) { 153 this.accept = accept; 154 } 155 156 161 public void setIdentifier(Identifier identifier) { 162 this.identifier = identifier; 163 } 164 } | Popular Tags |