WSDLFactory wsdlFactory,
XSDFactory xsdFactory,
DocumentBuilderFactory documentBuilderFactory,
Monitor monitor) {
WSDLInterface wsdlInterface = wsdlFactory.createWSDLInterface();
WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition();
Definition def = null;
try {
Interface2WSDLGenerator wsdlGenerator =
new Interface2WSDLGenerator(requiresSOAP12, resolver, dataBindings, xsdFactory, documentBuilderFactory, monitor);
def = wsdlGenerator.generate(javaInterface, wsdlDefinition);
} catch (WSDLException e) {
throw new WSDLGenerationException(e);
}
// for debugging
if (printWSDL) {
try {
System.out.println("Generated WSDL for Java interface " + javaInterface.getName() + " class " + javaInterface.getJavaClass().getName());
WSDLWriter writer = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
writer.writeWSDL(def, System.out);
} catch (WSDLException e) {
throw new WSDLGenerationException(e);
}
}
wsdlDefinition.setDefinition(def);
wsdlInterface.setWsdlDefinition(wsdlDefinition);
wsdlInterface.setRemotable(true);
wsdlInterface.setUnresolved(false);
wsdlInterface.setRemotable(true);
PortType portType = (PortType)def.getAllPortTypes().values().iterator().next();
wsdlInterface.setPortType(portType);
try {
wsdlFactory.createWSDLInterface(wsdlInterface, portType, wsdlDefinition, resolver, monitor);
} catch (InvalidInterfaceException e) {
throw new WSDLGenerationException(e);
}
// copy operation intents and policy sets from Java to WSDL interface
// in case we need to refer to them in later processing
for(Operation javaOperation : javaInterface.getOperations()){
for(Operation wsdlOperation : wsdlInterface.getOperations()){
if (wsdlOperation.getName().equals(javaOperation.getName())){
wsdlOperation.getRequiredIntents().addAll(javaOperation.getRequiredIntents());
wsdlOperation.getPolicySets().addAll(javaOperation.getPolicySets());
break;
}