1 16 package org.apache.axis2.saaj; 17 18 import org.apache.axis2.om.OMAbstractFactory; 19 import org.apache.axis2.om.OMElement; 20 import org.apache.axis2.om.OMFactory; 21 import org.apache.axis2.soap.SOAPFactory; 22 import org.w3c.dom.Document ; 23 24 import javax.xml.namespace.QName ; 25 import javax.xml.soap.*; 26 import java.util.Locale ; 27 28 34 public class SOAPBodyImpl extends SOAPElementImpl implements SOAPBody { 35 39 private org.apache.axis2.soap.SOAPBody omSOAPBody; 40 41 46 public SOAPBodyImpl(org.apache.axis2.soap.SOAPBody omSoapBody) 47 { 48 super(omSoapBody); 49 this.omSOAPBody = omSoapBody; 50 } 51 52 58 public SOAPFault addFault() throws SOAPException { 59 try{ 60 SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory(); 62 org.apache.axis2.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(omSOAPBody, new Exception ("No explicit faultstring available")); 63 omSOAPBody.addFault(omSoapFault); 64 return (new SOAPFaultImpl(omSoapFault)); 65 }catch(Exception e) 66 { 67 throw new SOAPException(e); 68 } 69 } 70 71 76 public boolean hasFault() { 77 return omSOAPBody.hasFault(); 78 } 79 80 85 public SOAPFault getFault() { 86 return (new SOAPFaultImpl(omSOAPBody.getFault())); 87 } 88 89 96 public SOAPBodyElement addBodyElement(Name name) throws SOAPException { 97 98 try { 99 OMFactory omFactory = OMAbstractFactory.getOMFactory(); 100 QName qname = new QName (name.getURI(), name.getLocalName(), name.getPrefix()); 101 OMElement bodyElement = omFactory.createOMElement(qname, omSOAPBody); 102 omSOAPBody.addChild(bodyElement); 103 return (new SOAPBodyElementImpl(bodyElement)); 104 } catch (Exception e) 105 { 106 throw new SOAPException(e); 107 } 108 } 109 110 118 public SOAPFault addFault(Name faultCode, String faultString, Locale locale) 119 throws SOAPException { 120 try{ 121 SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory(); 127 org.apache.axis2.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(omSOAPBody, new Exception (faultString)); 128 omSOAPBody.addFault(omSoapFault); 129 return (new SOAPFaultImpl(omSoapFault)); 130 }catch(Exception e) 131 { 132 throw new SOAPException(e); 133 } 134 } 135 136 144 public SOAPFault addFault(Name faultCode, String faultString) 145 throws SOAPException { 146 try{ 147 SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory(); 152 org.apache.axis2.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(omSOAPBody, new Exception (faultString)); 153 omSOAPBody.addFault(omSoapFault); 154 return (new SOAPFaultImpl(omSoapFault)); 155 }catch(Exception e) 156 { 157 throw new SOAPException(e); 158 } 159 } 160 161 168 public SOAPBodyElement addDocument(Document document) throws SOAPException { 169 172 return null; 173 } 174 175 } 176 | Popular Tags |