* @throws IOException
* @throws IllegalArgumentException mappingfilename is null
*/
public JavaWsdlMapping generate() throws IOException
{
MappingFileGeneratorHelper helper = new MappingFileGeneratorHelper(this.wsdlDefinitions, this.serviceName, this.namespacePackageMap, this.serviceEndpointInterface,
this.typeMapping, this.parameterStyle);
JavaWsdlMapping jwm = new JavaWsdlMapping();
//If the schema has types, we will need to generate the java/xml type mapping
helper.constructJavaXmlTypeMapping(jwm);
WSDLService[] services = wsdlDefinitions.getServices();
int lenServices = 0;
if (services != null)
lenServices = services.length;
for (int i = 0; i < lenServices; i++)
{
WSDLService wsdlService = services[i];
jwm.addServiceInterfaceMappings(helper.constructServiceInterfaceMapping(jwm, wsdlService));
helper.constructServiceEndpointInterfaceMapping(jwm, wsdlService);
}
// Add package to namespace mapping after helper has generated the rest of the file.
String targetNS = wsdlDefinitions.getTargetNamespace();
String typeNamespace = helper.getTypeNamespace();
if (typeNamespace == null)
typeNamespace = targetNS;
//Construct package mapping
//Check if the user has provided a typeNamespace
if (typeNamespace != null && typeNamespace.equals(targetNS) == false || isServerSideGeneration())
jwm.addPackageMapping(helper.constructPackageMapping(jwm, getPackageName(typeNamespace), typeNamespace));
jwm.addPackageMapping(helper.constructPackageMapping(jwm, getPackageName(targetNS), targetNS));
if (namespacePackageMap != null)
{
Set<String> keys = namespacePackageMap.keySet();
Iterator<String> iter = keys.iterator();
while (iter != null && iter.hasNext())
{
String ns = iter.next();
if (jwm.getPackageNameForNamespaceURI(ns) == null)
{
jwm.addPackageMapping(helper.constructPackageMapping(jwm, namespacePackageMap.get(ns), ns));
}
}
}
return jwm;