public AxisService populateService() throws AxisFault {
try {
setup();
// NOTE: set the axisService with the Parameter for the WSDL
// Definition after the rest of the work
if (wsdl4jDefinition == null) {
return null;
}
// setting target name space
axisService.setTargetNamespace(wsdl4jDefinition.getTargetNamespace());
axisService.setNamespaceMap(new NamespaceMap(wsdl4jDefinition.getNamespaces()));
Map importsMap = wsdl4jDefinition.getImports();
if (importsMap != null) {
List imports = new ArrayList(importsMap.keySet());
axisService.setImportedNamespaces(imports);
}
//TODO : find the service also in imported wsdls
Service wsdl4jService = findService(wsdl4jDefinition);
Binding binding = findBinding(wsdl4jDefinition, wsdl4jService);
Definition bindingWSDL = getParentDefinition(wsdl4jDefinition,
binding.getQName(), COMPONENT_BINDING, new HashSet());
Definition portTypeWSDL = getParentDefinition(bindingWSDL,
binding.getPortType().getQName(), COMPONENT_PORT_TYPE, new HashSet());
PortType portType = portTypeWSDL.getPortType(binding.getPortType().getQName());
if (portType == null) {
throw new AxisFault("There is no port type associated with the binding");
}
// create new Schema extensions element for wrapping
// (if its present)
Element[] schemaElements = generateWrapperSchema(schemaMap, binding, portType);
processTypes(wsdl4jDefinition, axisService);
// add the newly created schemas
if (schemaElements != null && schemaElements.length > 0) {
for (int i = 0; i < schemaElements.length; i++) {
Element schemaElement = schemaElements[i];
if (schemaElement != null) {
axisService.addSchema(getXMLSchema(schemaElement, null));
}
}
}
// copy the documentation element content to the description
Element documentationElement = wsdl4jDefinition.getDocumentationElement();
addDocumentation(axisService, documentationElement);
axisService.setName(wsdl4jService.getQName().getLocalPart());
populateEndpoints(binding, bindingWSDL,wsdl4jService, portType, portTypeWSDL);
processPoliciesInDefintion(wsdl4jDefinition);
axisService.getPolicyInclude().setPolicyRegistry(registry);
// Setting wsdl4jdefintion to the axisService parameter include list,
// so if someone needs to use the definition directly,
// he can do that by getting the parameter
Parameter wsdlDefinitionParameter = new Parameter();
wsdlDefinitionParameter.setName(WSDLConstants.WSDL_4_J_DEFINITION);
if (!(wsdl4jDefinition instanceof WSDLDefinitionWrapper)) {
AxisConfiguration ac = axisService.getAxisConfiguration();
if (ac == null) {
ac = this.axisConfig;
}
WSDLDefinitionWrapper wrapper = new WSDLDefinitionWrapper(wsdl4jDefinition, ac);
wsdlDefinitionParameter.setValue(wrapper);
} else {
wsdlDefinitionParameter.setValue(wsdl4jDefinition);
}
axisService.addParameter(wsdlDefinitionParameter);
axisService.setWsdlFound(true);
axisService.setCustomWsdl(true);
return axisService;
} catch (WSDLException e) {
log.error(e.getMessage(), e);
throw AxisFault.makeFault(e);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw AxisFault.makeFault(e);
}
}
Populates a given service. |