Definition definition;
try {
definition = readWSDL(uri);
} catch (WSDLException e) {
throw new CodeGenerationException(e);
}
HashSet<String> interestedPorts = ports == null ? null : new HashSet<String>(Arrays.asList(ports));
// Service service=(Service)definition.getServices().values().().next();
HashSet<QName> donePortTypes= new HashSet<QName>();
for (Iterator sIter = definition.getServices().values().iterator(); sIter.hasNext(); ) {
Service service = (Service) sIter.next();
QName serviceQname = service.getQName();
for (Iterator pIter= service.getPorts().values().iterator(); pIter.hasNext(); ) {
Port port= (Port) pIter.next();
if(interestedPorts != null && ! interestedPorts.contains(port.getName())) continue;//not iterested.
PortType portType= getPortType(port);
if(null == portType) continue; // not connected.
QName pQName= portType.getQName();
if(donePortTypes.contains(pQName)) continue; //allready did it.
donePortTypes.add(pQName);
if (packageName == null) {
//use JAXWS/JAXB NS->package default algorithm, not the SDO/EMF one
packageName = XJC.getDefaultPackageName(definition.getTargetNamespace());
}
//
// Use WSDL4J object to generate exception classes
//
generateFaults(packageName, portType, typeMapping);
JavaTypeMapper typeMapper = new JavaTypeMapper();
for (Map.Entry<QName, SDODataBindingTypeMappingEntry> e : typeMapping.entrySet()) {
typeMapper.addTypeMappingObject(e.getKey(), e.getValue());
// Added for generation of exceptions from faults
typeMapper.addTypeMappingName(e.getKey(), e.getValue().getClassName());
}
AxisService axisService;
WSDL11ToAxisServiceBuilder builder;
try {
//
// Added since at a newer level of Axis2, this doesn't work
// without the setCodegen(true)
//
builder = new WSDL11ToAxisServiceBuilder(definition, serviceQname, port.getName());
builder.setCodegen(true);
axisService = builder.populateService();
} catch (AxisFault e) {
throw new CodeGenerationException(e);
}
axisService.setName(port.getBinding().getPortType().getQName().getLocalPart());
CodeGenConfiguration codegenConfiguration = new CodeGenConfiguration(Collections.EMPTY_MAP);
codegenConfigurations.add(codegenConfiguration);