protected List<JavaField> buildFields(final Method method, final MessageInfo message) {
List<JavaField> fields = new ArrayList<JavaField>();
final Class<?> returnType = method.getReturnType();
JavaField field = new JavaField();
if (CollectionUtils.isEmpty(message.getMessageParts())) {
return fields;
}
MessagePartInfo part = message.getMessageParts().get(0);
field.setName(part.getName().getLocalPart());
field.setTargetNamespace(part.getName().getNamespaceURI());
if (method.getAnnotation(WebResult.class) == null
&& method.getAnnotation(javax.xml.ws.ResponseWrapper.class) == null
|| method.getAnnotation(WebResult.class) != null
&& method.getAnnotation(WebResult.class).targetNamespace().equals("")) {
field.setTargetNamespace("");
}
boolean hasReturnType = false;
if (!returnType.isAssignableFrom(void.class)) {
hasReturnType = true;
String type = getTypeString(method.getGenericReturnType());
List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method);
field.setType(type);
field.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
}
fields.add(field);
final Type[] paramClasses = method.getGenericParameterTypes();
for (MessagePartInfo mpi : message.getMessageParts()) {
int idx = hasReturnType ? mpi.getIndex() - 1 : mpi.getIndex();
if (idx >= 0) {
String name = mpi.getName().getLocalPart();
Type t = paramClasses[idx];
String type = getTypeString(t);
JavaField jf = new JavaField(name, type, "");
List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method, idx - 1);
jf.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
if (t instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType)t;
Class c = (Class)pt.getRawType();
if (Holder.class.isAssignableFrom(c)) {
Annotation[][] paramAnnotations = method.getParameterAnnotations();
WebParam wParam = getWebParamAnnotation(paramAnnotations[idx]);
if (wParam != null && !StringUtils.isEmpty(wParam.targetNamespace())) {
jf.setTargetNamespace(wParam.targetNamespace());
}
}
}
fields.add(jf);
}