Index: src/org/apache/axis/message/RPCParam.java =================================================================== --- src/org/apache/axis/message/RPCParam.java (revision 417141) +++ src/org/apache/axis/message/RPCParam.java (working copy) @@ -191,8 +191,19 @@ QName itemQName = paramDesc.getItemQName(); if (itemQName == null) { MessageContext mc = context.getMessageContext(); - if (mc != null && mc.getOperation() != null && mc.getOperation().getStyle() == Style.DOCUMENT) { - itemQName = Constants.QNAME_LITERAL_ITEM; + // to be removed: +// if (mc != null && mc.getOperation() != null && mc.getOperation().getStyle() == Style.DOCUMENT) { +// itemQName = Constants.QNAME_LITERAL_ITEM; +// } + + //arrays were not serialized correctly when using document/literal wrapped + if (mc != null && mc.getOperation() != null) { + if (mc.getOperation().getStyle() == Style.DOCUMENT) { + itemQName = Constants.QNAME_LITERAL_ITEM; + } else if (mc.getOperation().getStyle() == Style.WRAPPED) { + itemQName = new QName(xmlType.getNamespaceURI(), + Constants.QNAME_LITERAL_ITEM.getLocalPart()); + } } } context.setItemQName(itemQName); Index: src/org/apache/axis/encoding/ser/BeanSerializerFactory.java =================================================================== --- src/org/apache/axis/encoding/ser/BeanSerializerFactory.java (revision 417141) +++ src/org/apache/axis/encoding/ser/BeanSerializerFactory.java (working copy) @@ -17,7 +17,11 @@ package org.apache.axis.encoding.ser; import java.io.IOException; +import java.lang.reflect.Method; +import java.util.StringTokenizer; +import org.apache.axis.Constants; +import org.apache.axis.description.ElementDesc; import org.apache.axis.description.TypeDesc; import org.apache.axis.encoding.Serializer; import org.apache.axis.utils.BeanPropertyDescriptor; @@ -49,16 +53,119 @@ if (JavaUtils.isEnumClass(javaType)) { serClass = EnumSerializer.class; } - + typeDesc = TypeDesc.getTypeDescForClass(javaType); + // Added to make sure we register a typedesc for the so that + // correct namespaces will be used + if (javaType != null && xmlType != null + && serClass != EnumSerializer.class && typeDesc == null) { + registerTypeDescForBean(javaType); + //lookup the typedesc again to see if it is registered now + typeDesc = TypeDesc.getTypeDescForClass(javaType); + } + if (typeDesc != null) { propertyDescriptor = typeDesc.getPropertyDescriptors(); } else { propertyDescriptor = BeanUtils.getPd(javaType, null); } } + + /** + * Register a TypeDesc for the given Java Bean Class and its methods. Main + * purpose is to make sure that correct namespaces are used Only tested with + * DOCUMENT/LITERAL WRAPPED + * + * @param c + */ + private void registerTypeDescForBean(Class c) { + + String uri = convertToURI(c); + String type = convertToType(c); + TypeDesc td = new TypeDesc(c, true); + td.setXmlType(new QName(uri, type)); + + Method[] methods = c.getMethods(); + for (int i = 0; i < methods.length; i++) { + Class declaringClass = methods[i].getDeclaringClass(); + String name = methods[i].getName(); + + // check if we found a valid "bean method", and then add it to the + // collection. + //we only look for "get" not "set" because of java beans get/set + // model + if (!declaringClass.equals(Object.class) && name.length() > 3 + && (name.startsWith("get"))) { + + StringBuffer buf = new StringBuffer(); + // append the "raw" name + buf.append(name); + // remove the get/set prefix + buf.delete(0, 3); + // make sure first char is lowercase + buf.replace(0, 1, buf.substring(0, 1).toLowerCase()); + + ElementDesc elemField = new ElementDesc(); + elemField.setFieldName(buf.toString()); + String declURI = convertToURI(methods[i].getDeclaringClass()); + elemField.setXmlName(new QName(declURI, buf.toString())); + elemField.setNillable(true); + + if (methods[i].getReturnType().isArray()) { + QName itemQName = new QName(Constants.QNAME_LITERAL_ITEM + .getNamespaceURI(), Constants.QNAME_LITERAL_ITEM + .getLocalPart()); + elemField.setItemQName(itemQName); + } + + td.addFieldDesc(elemField); + } + } + + if (td != null && c != null) { + TypeDesc.registerTypeDescForClass(c, td); + } + } + + /** + * Create namespace from the class package. + * + * @param c + * @return namespace that is associated with the package the current class + * is located in + */ + private String convertToURI(Class c) { + StringBuffer buf = new StringBuffer(); + StringTokenizer tokenizer = new StringTokenizer(c.getName(), "."); + int tokenSize = tokenizer.countTokens(); + + for (int i = 0; i < tokenSize - 1; i++) { + buf.insert(0, tokenizer.nextToken()); + if (i < tokenSize - 2) + buf.insert(0, "."); + } + buf.insert(0, "http://"); + + return buf.toString(); + } + + /** + * Find the classes name as a string and without packages + * + * @param c + * @return name of class without packages + */ + private String convertToType(Class c) { + int index = c.getName().lastIndexOf('.'); + String qname = c.getName(); + if (index < 0) + return qname; + + return qname.substring(index + 1, qname.length()); + } + public javax.xml.rpc.encoding.Serializer getSerializerAs(String mechanismType) throws JAXRPCException { return (Serializer) super.getSerializerAs(mechanismType); Index: src/org/apache/axis/encoding/SerializationContext.java =================================================================== --- src/org/apache/axis/encoding/SerializationContext.java (revision 417141) +++ src/org/apache/axis/encoding/SerializationContext.java (working copy) @@ -1501,6 +1501,13 @@ // in the interop tests. //if (name.equals(multirefQName) && type != null) // name = type; + + //Make sure arrays "item" tag is given a correct namespace + //only tested using document/literal wrapped + if (elemQName.getNamespaceURI() == "") { + elemQName = new QName(this.nsStack.getNamespaceURI(""), + elemQName.getLocalPart()); + } ser.serialize(elemQName, attributes, value, this); return; }