1 17 18 package org.apache.sandesha.ws.rm; 19 20 import org.apache.axis.message.MessageElement; 21 import org.apache.axis.message.SOAPEnvelope; 22 import org.apache.axis.message.SOAPHeaderElement; 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 34 public class SequenceFault extends MessageElement implements IRmElement { 35 36 37 private MessageElement sequenceFault; 38 39 private FaultCode faultCode; 40 41 public SequenceFault() { 42 sequenceFault = new MessageElement(); 43 sequenceFault.setName(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.SEQUENCE_FAULT); 44 } 45 46 47 public MessageElement getSoapElement() throws SOAPException { 48 49 50 sequenceFault.addChildElement(faultCode.getSoapElement()); 51 52 return sequenceFault; 53 } 54 55 56 public SOAPEnvelope toSoapEnvelop(SOAPEnvelope envelope) throws Exception { 57 58 SOAPEnvelope env = envelope; 59 60 if (env.getHeader() == null) { 61 env.addHeader(); 62 } 63 64 Name name = env.createName("", Constants.WSRM.NS_PREFIX_RM, 65 Constants.WSRM.NS_URI_RM); 66 SOAPHeaderElement headerElement = (SOAPHeaderElement) env.getHeader() 67 .addHeaderElement(name); 68 69 headerElement.setActor(null); 70 headerElement.setName(Constants.WSRM.SEQUENCE_FAULT); 71 headerElement.setMustUnderstand(true); 72 73 if (faultCode != null) { 74 faultCode.toSOAPEnvelope(headerElement); 75 } 76 77 return env; 78 } 79 80 81 public SequenceFault fromSOAPEnveploe(SOAPHeaderElement headerElement) { 82 Iterator iterator = headerElement.getChildElements(); 83 MessageElement childElement; 84 85 while (iterator.hasNext()) { 86 childElement = (MessageElement) iterator.next(); 87 88 if (childElement.getName().equals(Constants.WSRM.NS_PREFIX_RM + Constants.COLON + Constants.WSRM.FAULT_CODE)) { 89 faultCode = new FaultCode(); 90 faultCode.fromSOAPEnvelope(childElement); 91 } 92 93 94 } 95 96 return this; 97 } 98 99 104 105 111 public void addChildElement(MessageElement element) throws SOAPException { 112 sequenceFault.addChildElement(element); 113 } 114 115 public MessageElement getSequenceFault() { 116 return sequenceFault; 117 } 118 119 public void setSequenceFault(MessageElement sequenceFault) { 120 this.sequenceFault = sequenceFault; 121 } 122 } 123 | Popular Tags |