Code example for HttpResponse

Methods: addHeader, setStatusCode

0
                    .getServices().get(serviceName);
            if (service != null) {
                try { 
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    service.printSchema(baos);
                    response.addHeader(CONTENT_TYPE, TEXT_XML);
                    serverHandler.commitResponseHideExceptions(conn, response);
                    os.write(baos.toByteArray());
                    closeOutputStream(os);
 
                } catch (Exception e) {
                    handleBrowserException(response, conn, os,
                            "Error generating ?xsd output for service : " + serviceName, e);
                } 
            } else { 
                processGetAndDelete(request, response, messageCtx, conn, os,
                        serviceName, isRestDispatching);
            } 
 
        } else { 
            //cater for named xsds - check for the xsd name 
            String schemaName = parameters.get("xsd");
            AxisService service = cfgCtx.getAxisConfiguration()
                    .getServices().get(serviceName);
 
            if (service != null) {
                //run the population logic just to be sure 
                service.populateSchemaMappings();
                //write out the correct schema 
                Map schemaTable = service.getSchemaMappingTable();
                XmlSchema schema = (XmlSchema) schemaTable.get(schemaName);
                if (schema == null) {
                    int dotIndex = schemaName.indexOf('.');
                    if (dotIndex > 0) {
                        String schemaKey = schemaName.substring(0, dotIndex);
                        schema = (XmlSchema) schemaTable.get(schemaKey);
                    } 
                } 
                //schema found - write it to the stream 
                if (schema != null) {
                    try { 
                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        schema.write(baos);
                        response.addHeader(CONTENT_TYPE, TEXT_XML);
                        serverHandler.commitResponseHideExceptions(conn, response);
                        os.write(baos.toByteArray());
                        closeOutputStream(os);
                    } catch (Exception e) {
                        handleBrowserException(response, conn, os,
                                "Error generating named ?xsd output for service : " + serviceName, e);
                    } 
 
                } else { 
                    // no schema available by that name  - send 404 
                    response.setStatusCode(HttpStatus.SC_NOT_FOUND);
                    closeOutputStream(os);
                } 
            } else { 
                processGetAndDelete(request, response, messageCtx, conn, os,
                        serviceName, isRestDispatching);