Refer to my answer to a similar Stack Overflow question, where I describe a couple of ways you can create a new package programatically: [url=http://stackoverflow.com/questions/20104411/package-creation-in-webMethods/20133559#20133559]Package creation in WebMethods - Stack Overflow.
Also, since you want to create a flow service already populated with code (my answer on the post you link to only creates a new empty flow service), I would suggest you instead use file based approach to creating services as follows:
- Create a template service that includes the code that you need, and copy/save the resulting flow.xml and node.ndf files from the relevant ./packages//ns/// directory - these files are the template files you will use to create new services.
- Create a new “create service from template” service that takes in the fully-qualified name of a new service to create and the package to create it: then code it to create the package if it doesn’t already exist (using one of the techniques from my Stack Overflow answer), create a new directory for the required new service in the relevant ./packages//ns/ directory, then write your template flow.xml and node.ndf files to that directory, then reload the affected package.
#Flow-and-Java-services#webMethods#Integration-Server-and-ESB