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.SOAPFaultSubCode; 10 import org.apache.axis2.soap.SOAPFaultValue; 11 import org.apache.axis2.soap.impl.llom.SOAPFaultCodeImpl; 12 import org.apache.axis2.soap.impl.llom.SOAPProcessingException; 13 14 import javax.xml.stream.XMLStreamException; 15 import javax.xml.stream.XMLStreamWriter; 16 17 34 35 public class SOAP11FaultCodeImpl extends SOAPFaultCodeImpl{ 36 44 public SOAP11FaultCodeImpl(SOAPFault parent, OMXMLParserWrapper builder) { 45 super(parent, builder); 46 } 47 48 52 public SOAP11FaultCodeImpl(SOAPFault parent) throws SOAPProcessingException { 53 super(parent, false); 54 } 55 56 57 public void setSubCode(SOAPFaultSubCode subCode) throws SOAPProcessingException { 58 if (!(subCode instanceof SOAP11FaultSubCodeImpl)) { 59 throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault Sub Code. But received some other implementation"); 60 } 61 super.setSubCode(subCode); 62 } 63 64 public void setValue(SOAPFaultValue value) throws SOAPProcessingException { 65 if (!(value instanceof SOAP11FaultValueImpl)) { 66 throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault Value. But received some other implementation"); 67 } 68 super.setValue(value); 69 } 70 71 protected void checkParent(OMElement parent) throws SOAPProcessingException { 72 if (!(parent instanceof SOAP11FaultImpl)) { 73 throw new SOAPProcessingException("Expecting SOAP 1.1 implementation of SOAP Fault as the parent. But received some other implementation"); 74 } 75 } 76 77 protected void serialize(OMOutput omOutput, boolean cache) throws XMLStreamException { 78 79 short builderType = PULL_TYPE_BUILDER; if (builder != null) { 82 builderType = this.builder.getBuilderType(); 83 } 84 if ((builderType == PUSH_TYPE_BUILDER) 85 && (builder.getRegisteredContentHandler() == null)) { 86 builder.registerExternalContentHandler(new StreamWriterToContentHandlerConverter(omOutput)); 87 } 88 89 XMLStreamWriter writer = omOutput.getXmlStreamWriter(); 90 if (this.getNamespace() != null) { 91 String prefix = this.getNamespace().getPrefix(); 92 String nameSpaceName = this.getNamespace().getName(); 93 writer.writeStartElement(prefix, SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME, 94 nameSpaceName); 95 }else{ 96 writer.writeStartElement(SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME); 97 } 98 99 OMSerializerUtil.serializeAttributes(this, omOutput); 100 OMSerializerUtil.serializeNamespaces(this, omOutput); 101 102 103 String text = this.getValue().getText(); 104 writer.writeCharacters(text); 105 writer.writeEndElement(); 106 107 if (this.nextSibling != null) { 109 nextSibling.serialize(omOutput); 110 } else if (this.parent != null) { 111 if (!this.parent.isComplete()) { 112 builder.setCache(cache); 113 builder.next(); 114 } 115 } 116 117 } 118 119 120 } 121 | Popular Tags |