1 17 18 package org.apache.sandesha.ws.rm; 19 20 import org.apache.axis.message.MessageElement; 21 import org.apache.axis.message.addressing.Address; 22 import org.apache.sandesha.Constants; 23 24 import javax.xml.soap.SOAPException ; 25 import java.util.Iterator ; 26 27 public class AcksTo implements IRmElement { 28 private Address address; 29 private MessageElement acksToElement; 30 31 34 public AcksTo() { 35 } 36 37 public AcksTo(Address address) { 38 acksToElement = new MessageElement(); 39 acksToElement.setName(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.ACKS_TO); 40 this.address = address; 41 } 42 43 49 public AcksTo fromSOAPEnvelope(MessageElement element) throws SOAPException { 50 51 Iterator iterator = element.getChildElements(); 52 MessageElement childElement; 53 try { 54 while (iterator.hasNext()) { 55 childElement = (MessageElement) iterator.next(); 56 if (childElement.getName().equals(org.apache.axis.message.addressing.Constants.NS_PREFIX_ADDRESSING + 57 Constants.COLON + 58 org.apache.axis.message.addressing.Constants.ADDRESS)) { 59 String uri = childElement.getFirstChild().getFirstChild().toString(); 60 address = new Address(uri); 61 } 62 if (childElement.getName().equals(org.apache.axis.message.addressing.Constants.ADDRESS)) { 63 String uri = childElement.getFirstChild().getNodeValue(); 64 address = new Address(uri); 65 } 66 } 67 } catch (Exception e) { 68 throw new SOAPException (e); 69 } 70 return this; 71 } 72 73 80 public MessageElement toSOAPEnvelope(MessageElement msgElement) throws SOAPException { 81 MessageElement messageElement = new MessageElement("", Constants.WSRM.NS_PREFIX_RM, 82 Constants.WSRM.NS_URI_RM); 83 messageElement.setName(Constants.WSRM.ACKS_TO); 84 address.append(messageElement); 85 msgElement.addChildElement(messageElement); 86 return msgElement; 87 } 88 89 public MessageElement getSoapElement() throws SOAPException { 90 address.append(acksToElement); 91 return acksToElement; 92 } 93 94 99 public void addChildElement(MessageElement element) { 100 } 102 103 108 public Address getAddress() { 109 return address; 110 } 111 112 117 public void setAddress(Address address) { 118 this.address = address; 119 } 120 121 122 } 123 | Popular Tags |