This example code is suitable for the basis of an Ant task:
import javax.xml.stream.XMLStreamException;
import javax.xml.transform.TransformerFactory;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
import org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection;
....
private String generateWsdlFromSpringInfrastructure() throws Exception
{
// We only need to specify the top-level XSD
FileSystemResource messagesXsdResource = new FileSystemResource("C:/MyProject/xsds/my-messages.xsd");
CommonsXsdSchemaCollection schemaCollection = new CommonsXsdSchemaCollection(new Resource[] {messagesXsdResource});
// In-line all the included schemas into the including schema
schemaCollection.setInline(true);
schemaCollection.afterPropertiesSet();
DefaultWsdl11Definition definition = new DefaultWsdl11Definition();
definition.setSchemaCollection(schemaCollection);
definition.setPortTypeName(portTypeName);
definition.setLocationUri("http://localhost:8080/myProject/services");
definition.setTargetNamespace("http://www.acme.com/my-project/definitions");
definition.afterPropertiesSet();
StringResult wsdlResult = new StringResult();
TransformerFactory.newInstance().newTransformer().transform(definition.getSource(), wsdlResult);
return wsdlResult.toString();
}