SOAPExceptionSerializer implements ExceptionSerializer { public void serializeExceptionToXML( XMLStreamWriter writer, OWSException owsException ) throws XMLStreamException { if ( owsException == null || writer == null || !( owsException instanceof SOAPException ) ) { return; } SOAPException exception = (SOAPException) owsException; String ns = factory.getNamespace().getNamespaceURI(); String prefix = factory.getNamespace().getPrefix(); if ( isSoap11( ns ) ) { serializeSoapException11( writer, exception, ns, prefix ); } else { serializeSoapException12( writer, exception, ns, prefix ); } } SOAPExceptionSerializer( SOAPVersion version, SOAPHeader header, SOAPFactory factory,
                                    XMLExceptionSerializer detailSerializer ); @Override void serializeException( HttpResponseBuffer response, OWSException exception ); void serializeExceptionToXML( XMLStreamWriter writer, OWSException owsException );  }
@SuppressWarnings("deprecation") @Test public void testSerializeExceptionToXML_SOAP11() throws Exception { SOAP11Factory factory = new SOAP11Factory(); XMLExceptionSerializer detailSerializer = new OWS110ExceptionReportSerializer( new Version( 2, 0, 0 ) ); SOAPExceptionSerializer soapExceptionSerializer = new SOAPExceptionSerializer( factory.getSOAPVersion(), null, factory, detailSerializer ); SOAPException soapException = createException(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter( stream ); writer.writeStartDocument(); soapExceptionSerializer.serializeExceptionToXML( writer, soapException ); writer.writeEndDocument(); writer.close(); }
@SuppressWarnings("deprecation") @Test public void testSerializeExceptionToXML_SOAP12() throws Exception { SOAP12Factory factory = new SOAP12Factory(); SOAPExceptionSerializer soapExceptionSerializer = createExceptionSerializer( factory ); SOAPException soapException = createException(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter( stream ); writer.writeStartDocument(); soapExceptionSerializer.serializeExceptionToXML( writer, soapException ); writer.writeEndDocument(); writer.close(); }