public AxisServiceGenerator(){
super();
}
public AxisService getServiceFromWSDL(org.apache.geronimo.jaxws.PortInfo portInfo, String endpointClassName, Definition wsdlDefinition, ClassLoader classLoader) throws Exception {
WSDLToAxisServiceBuilder wsdlBuilder = null;
WSDLFactory factory = WSDLFactory.newInstance();
WSDLWriter writer = factory.newWSDLWriter();
ByteArrayOutputStream out = new ByteArrayOutputStream();
writer.writeWSDL(wsdlDefinition, out);
String wsdlContent = out.toString(WSDL_ENCODING); //Will the Axis2 give us this information soon ?
OMNamespace documentElementNS = ((OMElement)XMLUtils.toOM(new StringReader(wsdlContent))).getNamespace();
Map<QName, Service> serviceMap = wsdlDefinition.getServices();
Service wsdlService = serviceMap.values().iterator().next();
Map<String, Port> portMap = wsdlService.getPorts();
Port port = portMap.values().iterator().next();
String portName = port.getName();
QName serviceQName = wsdlService.getQName();
//Decide WSDL Version :
if(WSDLConstants.WSDL20_2006Constants.DEFAULT_NAMESPACE_URI.equals(documentElementNS.getNamespaceURI())){
wsdlBuilder = new WSDL20ToAxisServiceBuilder(new ByteArrayInputStream(wsdlContent.getBytes()), serviceQName, null);
}
else if(Constants.NS_URI_WSDL11.equals(documentElementNS.getNamespaceURI())){
wsdlBuilder = new WSDL11ToAxisServiceBuilder(wsdlDefinition, serviceQName , portName);
}
//populate with axis2 objects
AxisService service = wsdlBuilder.populateService();
service.addParameter(new Parameter(Constants.SERVICE_CLASS, endpointClassName));
service.setWsdlFound(true);
service.setClassLoader(classLoader);
//Going to create annotations by hand