1 package org.apache.axis2.soap.impl.llom.soap11; 2 3 import org.apache.axis2.om.OMElement; 4 import org.apache.axis2.om.OMOutput; 5 import org.apache.axis2.om.OMXMLParserWrapper; 6 import org.apache.axis2.om.impl.llom.OMSerializerUtil; 7 import org.apache.axis2.om.impl.llom.serialize.StreamWriterToContentHandlerConverter; 8 import org.apache.axis2.soap.SOAPFault; 9 import org.apache.axis2.soap.SOAPFaultText; 10 import org.apache.axis2.soap.impl.llom.SOAPFaultReasonImpl; 11 import org.apache.axis2.soap.impl.llom.SOAPProcessingException; 12 13 import javax.xml.stream.XMLStreamException; 14 import javax.xml.stream.XMLStreamWriter; 15 16 32 public class SOAP11FaultReasonImpl extends SOAPFaultReasonImpl { 33 36 37 public SOAP11FaultReasonImpl(SOAPFault parent, OMXMLParserWrapper builder) { 38 super(parent, builder); 39 } 40 41 44 public SOAP11FaultReasonImpl(SOAPFault parent) throws SOAPProcessingException { 45 super(parent, false); 46 } 47 48 public void setSOAPText(SOAPFaultText soapFaultText) throws SOAPProcessingException { 49 if (!(soapFaultText instanceof SOAP11FaultTextImpl)) { 50 throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault Text. But received some other implementation"); 51 } 52 super.setSOAPText(soapFaultText); 53 } 54 55 protected void checkParent(OMElement parent) throws SOAPProcessingException { 56 if (!(parent instanceof SOAP11FaultImpl)) { 57 throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault as the parent. But received some other implementation"); 58 } 59 } 60 61 protected void serialize(OMOutput omOutput, boolean cache) throws XMLStreamException { 62 63 short builderType = PULL_TYPE_BUILDER; if (builder != null) { 66 builderType = this.builder.getBuilderType(); 67 } 68 if ((builderType == PUSH_TYPE_BUILDER) 69 && (builder.getRegisteredContentHandler() == null)) { 70 builder.registerExternalContentHandler(new StreamWriterToContentHandlerConverter(omOutput)); 71 } 72 73 XMLStreamWriter writer = omOutput.getXmlStreamWriter(); 74 if (this.getNamespace() != null) { 75 String prefix = this.getNamespace().getPrefix(); 76 String nameSpaceName = this.getNamespace().getName(); 77 writer.writeStartElement(prefix, SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME, 78 nameSpaceName); 79 }else{ 80 writer.writeStartElement(SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME); 81 } 82 OMSerializerUtil.serializeAttributes(this, omOutput); 83 OMSerializerUtil.serializeNamespaces(this, omOutput); 84 85 String text = this.getSOAPText().getText(); 86 writer.writeCharacters(text); 87 writer.writeEndElement(); 88 89 if (this.nextSibling != null) { 91 nextSibling.serialize(omOutput); 92 } else if (this.parent != null) { 93 if (!this.parent.isComplete()) { 94 builder.setCache(cache); 95 builder.next(); 96 } 97 } 98 99 } 100 101 102 } 103 | Popular Tags |