Return-Path: Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 5953 invoked by uid 500); 12 Mar 2003 17:53:04 -0000 Mailing-List: contact axis-dev-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@ws.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-dev@ws.apache.org Received: (qmail 5909 invoked by uid 500); 12 Mar 2003 17:53:04 -0000 Delivered-To: apmail-xml-axis-cvs@apache.org Message-ID: <20030312175306.44186.qmail@web12806.mail.yahoo.com> Date: Wed, 12 Mar 2003 09:53:06 -0800 (PST) From: Davanum Srinivas Reply-To: dims@yahoo.com Subject: Map/HashMap with .NET (was Re: cvs commit: xml-axis/java/src/org/apache/axis/encoding/ser MapDeserializer.java MapSerializer.java) To: axis-dev@ws.apache.org, xml-axis-cvs@apache.org In-Reply-To: <20030312174908.37212.qmail@icarus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Folks, Any objections to this check-in? Thanks, dims --- dims@apache.org wrote: > dims 2003/03/12 09:49:08 > > Modified: java/src/org/apache/axis/encoding/ser MapDeserializer.java > MapSerializer.java > Log: > Fix for Bug 17703 - Java2WSDL creates .Net interop incompatible map type > > Notes: > - Uses soapenc:Array > - Tested with .NET Framework SDK 1.1 > - See discussion (http://marc.theaimsgroup.com/?t=102650467100001&r=1&w=2) > > Revision Changes Path > 1.24 +13 -9 xml-axis/java/src/org/apache/axis/encoding/ser/MapDeserializer.java > > Index: MapDeserializer.java > =================================================================== > RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/MapDeserializer.java,v > retrieving revision 1.23 > retrieving revision 1.24 > diff -u -r1.23 -r1.24 > --- MapDeserializer.java 11 Dec 2002 22:38:15 -0000 1.23 > +++ MapDeserializer.java 12 Mar 2003 17:49:07 -0000 1.24 > @@ -143,16 +143,20 @@ > log.debug("Enter: MapDeserializer::onStartChild()"); > } > > - ItemHandler handler = new ItemHandler(this); > - > - // This item must be complete before we're complete... > - addChildDeserializer(handler); > - > - if (log.isDebugEnabled()) { > - log.debug("Exit: MapDeserializer::onStartChild()"); > + if(localName.equals("item")) { > + ItemHandler handler = new ItemHandler(this); > + > + // This item must be complete before we're complete... > + addChildDeserializer(handler); > + > + if (log.isDebugEnabled()) { > + log.debug("Exit: MapDeserializer::onStartChild()"); > + } > + > + return handler; > } > - > - return handler; > + > + return this; > } > > /** > > > > 1.20 +48 -22 xml-axis/java/src/org/apache/axis/encoding/ser/MapSerializer.java > > Index: MapSerializer.java > =================================================================== > RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/MapSerializer.java,v > retrieving revision 1.19 > retrieving revision 1.20 > diff -u -r1.19 -r1.20 > --- MapSerializer.java 11 Dec 2002 22:38:15 -0000 1.19 > +++ MapSerializer.java 12 Mar 2003 17:49:07 -0000 1.20 > @@ -56,6 +56,8 @@ > package org.apache.axis.encoding.ser; > > import org.apache.axis.Constants; > +import org.apache.axis.MessageContext; > +import org.apache.axis.schema.SchemaVersion; > import org.apache.axis.components.logger.LogFactory; > import org.apache.axis.encoding.SerializationContext; > import org.apache.axis.encoding.Serializer; > @@ -64,6 +66,7 @@ > import org.apache.commons.logging.Log; > import org.w3c.dom.Element; > import org.xml.sax.Attributes; > +import org.xml.sax.helpers.AttributesImpl; > > import javax.xml.namespace.QName; > import java.io.IOException; > @@ -86,6 +89,7 @@ > > // QNames we deal with > private static final QName QNAME_KEY = new QName("","key"); > + private static final QName QNAME_ITEMS = new QName("", "items"); > private static final QName QNAME_ITEM = new QName("", "item"); > private static final QName QNAME_VALUE = new QName("", "value"); > > @@ -111,6 +115,16 @@ > Map map = (Map)value; > > context.startElement(name, attributes); > + > + AttributesImpl itemsAttributes = new AttributesImpl(); > + String encodingURI = context.getMessageContext().getSOAPConstants().getEncodingURI(); > + String encodingPrefix = context.getPrefixForURI(encodingURI); > + String soapPrefix = context.getPrefixForURI(Constants.SOAP_MAP.getNamespaceURI()); > + itemsAttributes.addAttribute(encodingURI, "type", encodingPrefix + ":type", > + "CDATA", encodingPrefix + ":Array"); > + itemsAttributes.addAttribute(encodingURI, "arrayType", encodingPrefix + ":arrayType", > + "CDATA", soapPrefix + ":item["+map.size()+"]"); > + context.startElement(QNAME_ITEMS, itemsAttributes); > > for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) > { > @@ -127,6 +141,7 @@ > } > > context.endElement(); > + context.endElement(); > } > > public String getMechanismType() { return Constants.AXIS_SAX; } > @@ -145,32 +160,43 @@ > public Element writeSchema(Class javaType, Types types) throws Exception { > Element complexType = types.createElement("complexType"); > complexType.setAttribute("name", "Map"); > - types.writeSchemaElement(Constants.SOAP_MAP, complexType); > Element seq = types.createElement("sequence"); > complexType.appendChild(seq); > - > Element element = types.createElement("element"); > - element.setAttribute("name", "item"); > - element.setAttribute("minOccurs", "0"); > - element.setAttribute("maxOccurs", "unbounded"); > + element.setAttribute("name", "items"); > + element.setAttribute("nillable", "true"); > + element.setAttribute("type", types.getQNameString(new > QName(Constants.NS_URI_XMLSOAP,"ArrayOfitem"))); > seq.appendChild(element); > - > - Element subType = types.createElement("complexType"); > - element.appendChild(subType); > - > - Element all = types.createElement("all"); > - subType.appendChild(all); > - > - Element key = types.createElement("element"); > - key.setAttribute("name", "key"); > - key.setAttribute("type", "xsd:anyType"); > - all.appendChild(key); > - > - Element value = types.createElement("element"); > - value.setAttribute("name", "value"); > - value.setAttribute("type", "xsd:anyType"); > - all.appendChild(value); > - > + types.writeSchemaElement(Constants.SOAP_MAP, complexType); > + > + Element arrayType = types.createElement("complexType"); > + arrayType.setAttribute("name", "ArrayOfitem"); > + Element complexContent = types.createElement("complexContent"); > + arrayType.appendChild(complexContent); > + Element restriction = types.createElement("restriction"); > + restriction.setAttribute("base", "soapenc:Array"); > + complexContent.appendChild(restriction); > + Element attribute = types.createElement("attribute"); > + attribute.setAttribute("ref","soapenc:arrayType"); > + attribute.setAttribute("wsdl:arrayType",types.getQNameString(new > QName(Constants.NS_URI_XMLSOAP,"item[]"))); > + restriction.appendChild(attribute); > + types.writeSchemaElement(Constants.SOAP_MAP, arrayType); > + > + Element itemType = types.createElement("complexType"); > + itemType.setAttribute("name", "item"); > + Element seq2 = types.createElement("sequence"); > + itemType.appendChild(seq2); > + Element element2 = types.createElement("element"); > + element2.setAttribute("name", "key"); > + element2.setAttribute("nillable", "true"); > + element2.setAttribute("type", "xsd:string"); > + seq2.appendChild(element2); > + Element element3 = types.createElement("element"); > + element3.setAttribute("name", "value"); > + element3.setAttribute("nillable", "true"); > + element3.setAttribute("type", "xsd:string"); > + seq2.appendChild(element3); > + types.writeSchemaElement(Constants.SOAP_MAP, itemType); > return complexType; > } > } > > > ===== Davanum Srinivas - http://webservices.apache.org/~dims/ __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com