Create DocumentType from JavaService

Greetings,

I’ve a ticket to create a java service that should create a document type on the integration server. Now as this is quite simple with Designer/Developer I’m interested in doing it automatically with a service. I have an object that contains properties like XMLNamespace, Required, Allow null (FieldDesc). With a FieldDesc i have a descriptor for each field, and a String doctypeName. How can I create a doctype on the server? I can create a NSNode with Namespace.current().makeNode(NSName.create(doctypeName)) but how can i put in the fields?

Thanks,
Jozsef