# TypeHierarchyPrinterService.jws Sample

This topic inludes the source code for the TypeHierarchyPrinterService.jws Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/xmlBeans/schema/

## Sample Source Code

`01 package xmlBeans.schema; 02 03 import org.openuri.easypo.Customer; 04 import com.bea.xml.SchemaTypeSystem; 05 06 /** 07 @common:target-namespace namespace="http://workshop.bea.com/TypeHierarchyPrinterService" 08 */ 09 10 public class TypeHierarchyPrinterService implements com.bea.jws.WebService 11 { 12 /** 13 * Prints a hierarchical rendering of the schema types represented 14 * by the schema type system available to this application. 15 * A schema type system is a set of Java types corresponding to 16 * XML schema types. When you compile schema into Java types, 17 * those Java types (along with the built-in types they use or 18 * inherit from) become part of a schema type system. 19 * <br/><br/> 20 * The type system used by this sample is available to this code because 21 * the types are included in a JAR file on this application's 22 * classpath. These types are used by the various schema-related 23 * samples in the SamplesApp application. 24 * 25 * @common:operation 26 */ 27 public String printHierarchy() throws Exception 28 { 29 /** 30 * Create a Customer instance simply to get the type system 31 * it belongs to. 32 */ 33 Customer customer = Customer.Factory.newInstance(); 34 35 /** 36 * Get the type system from the Customer object. 37 */ 38 SchemaTypeSystem typeSystem = customer.schemaType().getTypeSystem(); 39 40 /** 41 * Pass the type system to a TypeHierarchyPrinter instance, 42 * which will walk through it, creating a hiearchical rendering 43 * of the schema types (including elements) defined in the 44 * schemas from which the type system was created. 45 */ 46 TypeHierarchyPrinter printer = new TypeHierarchyPrinter(); 47 48 return printer.printHierarchy(typeSystem); 49 } 50 }`