HashMap uniqueMethods = new HashMap();
XmlSchemaComplexType methodSchemaType;
XmlSchemaSequence sequence = null;
for (int i = 0; i < methods.length; i++) {
JMethod jMethod = methods[i];
JAnnotation methodAnnon= jMethod.getAnnotation(AnnotationConstants.WEB_METHOD);
if(methodAnnon!=null){
if(methodAnnon.getValue(AnnotationConstants.EXCLUDE).asBoolean()){
continue;
}
}
String methodName = getSimpleName(jMethod);
// no need to think abt this method , since that is system
// config method
if (excludeMethods.contains(getSimpleName(jMethod))) {
continue;
}
if (uniqueMethods.get(getSimpleName(jMethod)) != null) {
throw new Exception(
" Sorry we don't support methods overloading !!!! ");
}
if (!jMethod.isPublic()) {
// no need to generate Schema for non public methods
continue;
}
if (jMethod.getExceptionTypes().length > 0) {
/*
methodSchemaType = createSchemaTypeForMethodPart(getSimpleName(jMethod) + "Fault");
sequence = new XmlSchemaSequence();
XmlSchemaElement elt1 = new XmlSchemaElement();
elt1.setName(getSimpleName(jMethod) + "Fault");
elt1.setSchemaTypeName(typeTable.getQNamefortheType(Object.class.getName()));
sequence.getItems().add(elt1);
methodSchemaType.setParticle(sequence);
*/
// begin mj
JClass[] extypes = jMethod.getExceptionTypes() ;
for (int j= 0 ; j < extypes.length ; j++) {
JClass extype = extypes[j] ;
methodSchemaType = createSchemaTypeForMethodPart(extype.getSimpleName()+ "Fault");
sequence = new XmlSchemaSequence();
// methodSchemaType = createSchemaTypeForMethodPart(extype.getSimpleName());
// methodSchemaType.setParticle(sequence);
generateSchemaForType(sequence, extype, extype.getSimpleName());
methodSchemaType.setParticle(sequence);
}
// end mj
}
uniqueMethods.put(getSimpleName(jMethod), jMethod);
//create the schema type for the method wrapper
uniqueMethods.put(getSimpleName(jMethod), jMethod);
JParameter [] paras = jMethod.getParameters();
String parameterNames [] = null;
if (paras.length > 0) {
parameterNames = methodTable.getParameterNames(methodName);
sequence = new XmlSchemaSequence();
methodSchemaType = createSchemaTypeForMethodPart(getSimpleName(jMethod));
methodSchemaType.setParticle(sequence);
}
for (int j = 0; j < paras.length; j++) {
JParameter methodParameter = paras[j];
String parameterName =null;
JAnnotation paramterAnnon =
methodParameter.getAnnotation(AnnotationConstants.WEB_PARAM);
if(paramterAnnon!=null){
parameterName =
paramterAnnon.getValue(AnnotationConstants.NAME).asString();
}
if(parameterName==null||"".equals(parameterName)){
parameterName = (parameterNames != null && parameterNames[j] != null) ?
parameterNames[j] : getSimpleName(methodParameter);
}
JClass paraType = methodParameter.getType();
if(nonRpcMethods.contains(getSimpleName(jMethod))){
generateSchemaForType(sequence, null,getSimpleName(jMethod));
break;
} else {
generateSchemaForType(sequence, paraType,parameterName);
}
}
// for its return type
JClass returnType = jMethod.getReturnType();
if (!returnType.isVoidType()) {
methodSchemaType =
createSchemaTypeForMethodPart(getSimpleName(jMethod) + RESPONSE);
sequence = new XmlSchemaSequence();
methodSchemaType.setParticle(sequence);
JAnnotation returnAnnon =
jMethod.getAnnotation(AnnotationConstants.WEB_RESULT);
String returnName ="return";
if(returnAnnon!=null){
returnName= returnAnnon.getValue(AnnotationConstants.NAME).asString();
if(returnName!=null&&!"".equals(returnName)){
returnName ="return";