Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 176 invoked from network); 6 Jul 2004 21:19:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 6 Jul 2004 21:19:31 -0000 Received: (qmail 3515 invoked by uid 500); 6 Jul 2004 21:19:13 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 3178 invoked by uid 500); 6 Jul 2004 21:19:09 -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 3098 invoked by uid 99); 6 Jul 2004 21:19:08 -0000 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=RCVD_BY_IP,SB_NEW_BULK,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received: from [216.239.56.252] (HELO mproxy.gmail.com) (216.239.56.252) by apache.org (qpsmtpd/0.27.1) with SMTP; Tue, 06 Jul 2004 14:19:06 -0700 Received: by mproxy.gmail.com with SMTP id r65so263518cwc for ; Tue, 06 Jul 2004 14:18:39 -0700 (PDT) Received: by 10.11.117.12 with SMTP id p12mr101450cwc; Tue, 06 Jul 2004 14:18:39 -0700 (PDT) Message-ID: <19e0530f040706141842e10606@mail.gmail.com> Date: Tue, 6 Jul 2004 17:18:39 -0400 From: Davanum Srinivas Reply-To: dims@apache.org To: Jongjin Choi Subject: Re: cvs commit: ws-axis/java/test/message TestMessageElement.java Cc: "axis-dev@ws.apache.org" In-Reply-To: <19e0530f0407051150248a6344@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <19e0530f0407051150248a6344@mail.gmail.com> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Jongjin, I'd REALLY like to take a stab at fixing this before the next cut. i'd be grateful if you can help me with a test case to recreate the problem :) -- dims On Mon, 5 Jul 2004 14:50:30 -0400, Davanum Srinivas wrote: > Jongjin, > > I was hunting for a test case...can u please add it to JIRA? That's > exactly i had not marked the bug as closed :) > > thanks, > dims > > > > > On Mon, 5 Jul 2004 23:38:58 +0900, Jongjin Choi wrote: > > Hi, dims. > > > > I looked into the following MessageElement changes and ran a test. > > Does this change resolve the problem RPCParam <-> SOAP Element mapping > > addressed in http://nagoya.apache.org/jira/browse/AXIS-1416? > > > > I made a simple test and found that the problem is remaining. > > > > Without resolving the AXIS-1416, > > the standard JAX-RPC handler under Axis can not read or modify > > the second and below level SOAP body elements. > > > > Thanks. > > > > -----Original Message----- > > From: dims@apache.org [mailto:dims@apache.org] > > Sent: Thursday, June 24, 2004 9:28 PM > > To: ws-axis-cvs@apache.org > > Subject: cvs commit: ws-axis/java/test/message TestMessageElement.java > > > > dims 2004/06/24 05:27:38 > > > > Modified: java/test/wsdl/faults FaultServiceSoapBindingImpl.java > > java/src/org/apache/axis/message MessageElement.java > > java/test/wsdl/sequence SequenceService.java > > java/src/org/apache/axis/encoding > > SerializationContextImpl.java > > java/test/encoding TestDOM.java > > java/test/message TestMessageElement.java > > Log: > > Fix for AXIS-1350 - new MessageElement(new Element()) does not behave like > > an Element > > Fix for AXIS-616 - MessageElement is not for mortals > > Fix for AXIS-1054 - No way to non-default namespace prefixes when creating > > MessageElements from DOM elements > > Fix for AXIS-1403 - calling MessageElement#getChildren with a Text-Only > > content returns an empty list > > > > Notes: > > - traverse all the nodes recursively and create new MessageElement's for > > each node. > > > > Revision Changes Path > > 1.5 +1 -1 > > ws-axis/java/test/wsdl/faults/FaultServiceSoapBindingImpl.java > > > > Index: FaultServiceSoapBindingImpl.java > > =================================================================== > > RCS file: > > /home/cvs/ws-axis/java/test/wsdl/faults/FaultServiceSoapBindingImpl.java,v > > retrieving revision 1.4 > > retrieving revision 1.5 > > diff -u -r1.4 -r1.5 > > --- FaultServiceSoapBindingImpl.java 11 Dec 2002 22:40:20 -0000 1.4 > > +++ FaultServiceSoapBindingImpl.java 24 Jun 2004 12:27:37 -0000 1.5 > > @@ -23,7 +23,7 @@ > > public int throwExtensionFault(java.lang.String description) throws > > java.rmi.RemoteException, test.wsdl.faults.ExtensionFault { > > ExtensionType extension = new ExtensionType(); > > try { > > - extension.set_any(new MessageElement[] {new > > MessageElement(XMLUtils.newDocument().createElement(description))}); > > + extension.set_any(new MessageElement[] {new > > MessageElement(XMLUtils.newDocument().createElementNS(null,description))}); > > } catch (Exception e) { > > throw new java.rmi.RemoteException(e.getMessage()); > > } > > > > 1.173 +85 -36 > > ws-axis/java/src/org/apache/axis/message/MessageElement.java > > > > Index: MessageElement.java > > =================================================================== > > RCS file: > > /home/cvs/ws-axis/java/src/org/apache/axis/message/MessageElement.java,v > > retrieving revision 1.172 > > retrieving revision 1.173 > > diff -u -r1.172 -r1.173 > > --- MessageElement.java 23 Jun 2004 04:14:31 -0000 1.172 > > +++ MessageElement.java 24 Jun 2004 12:27:37 -0000 1.173 > > @@ -16,22 +16,6 @@ > > > > package org.apache.axis.message; > > > > -import java.io.Reader; > > -import java.io.Serializable; > > -import java.io.StringReader; > > -import java.io.StringWriter; > > -import java.util.ArrayList; > > -import java.util.Iterator; > > -import java.util.Vector; > > -import java.util.Enumeration; > > -import java.util.List; > > - > > -import javax.xml.namespace.QName; > > -import javax.xml.rpc.encoding.TypeMapping; > > -import javax.xml.soap.Name; > > -import javax.xml.soap.SOAPElement; > > -import javax.xml.soap.SOAPException; > > - > > import org.apache.axis.AxisFault; > > import org.apache.axis.Constants; > > import org.apache.axis.MessageContext; > > @@ -48,6 +32,9 @@ > > import org.apache.axis.utils.XMLUtils; > > import org.apache.commons.logging.Log; > > import org.w3c.dom.Attr; > > +import org.w3c.dom.CDATASection; > > +import org.w3c.dom.CharacterData; > > +import org.w3c.dom.Comment; > > import org.w3c.dom.DOMException; > > import org.w3c.dom.Document; > > import org.w3c.dom.Element; > > @@ -61,6 +48,21 @@ > > import org.xml.sax.SAXException; > > import org.xml.sax.helpers.AttributesImpl; > > > > +import javax.xml.namespace.QName; > > +import javax.xml.rpc.encoding.TypeMapping; > > +import javax.xml.soap.Name; > > +import javax.xml.soap.SOAPElement; > > +import javax.xml.soap.SOAPException; > > +import java.io.Reader; > > +import java.io.Serializable; > > +import java.io.StringReader; > > +import java.io.StringWriter; > > +import java.util.ArrayList; > > +import java.util.Enumeration; > > +import java.util.Iterator; > > +import java.util.List; > > +import java.util.Vector; > > + > > /* > > * MessageElement is the base type of nodes of the SOAP message parse > > tree. > > * > > @@ -106,8 +108,7 @@ > > protected int endEventIndex = -1; > > > > // ...or as DOM > > - protected Element elementRep = null; > > - protected Text textRep = null; > > + protected CharacterData textRep = null; > > > > protected MessageElement parent = null; > > > > @@ -163,12 +164,12 @@ > > > > public MessageElement(Element elem) > > { > > - elementRep = elem; > > namespaceURI = elem.getNamespaceURI(); > > name = elem.getLocalName(); > > + copyNode(elem); > > } > > > > - public MessageElement(Text text) > > + public MessageElement(CharacterData text) > > { > > textRep = text; > > namespaceURI = text.getNamespaceURI(); > > @@ -399,8 +400,7 @@ > > * protected int startEventIndex = 0; N? > > * protected int startContentsIndex = 0; N? > > * protected int endEventIndex = -1; N? > > - * protected Element elementRep = null; N? > > - * protected Text textRep = null; Y? > > + * protected CharacterData textRep = null; Y? > > * protected MessageElement parent = null; N > > * public ArrayList namespaces = null; Y > > * protected String encodingStyle = null; N? > > @@ -608,7 +608,13 @@ > > > > public short getNodeType() { > > if(this.textRep != null) { > > + if(textRep instanceof Comment) { > > + return COMMENT_NODE; > > + } else if(textRep instanceof CDATASection) { > > + return CDATA_SECTION_NODE; > > + } else { > > return TEXT_NODE; > > + } > > }else if(false){ > > return DOCUMENT_FRAGMENT_NODE; > > }else if(false){ > > @@ -908,11 +914,6 @@ > > log.error(Messages.getMessage("childPresent"), exc); > > throw exc; > > } > > - if (elementRep != null) { > > - SOAPException exc = new > > SOAPException(Messages.getMessage("xmlPresent")); > > - log.error(Messages.getMessage("xmlPresent"), exc); > > - throw exc; > > - } > > if (textRep != null) { > > SOAPException exc = new > > SOAPException(Messages.getMessage("xmlPresent")); > > log.error(Messages.getMessage("xmlPresent"), exc); > > @@ -1165,18 +1166,20 @@ > > */ > > protected void outputImpl(SerializationContext context) throws > > Exception > > { > > - if (elementRep != null) { > > - boolean oldPretty = context.getPretty(); > > - context.setPretty(false); > > - context.writeDOMElement(elementRep); > > - context.setPretty(oldPretty); > > - return; > > - } > > - > > if (textRep != null) { > > boolean oldPretty = context.getPretty(); > > context.setPretty(false); > > - context.writeSafeString(textRep.getData()); > > + if (textRep instanceof CDATASection) { > > + context.writeString(" > + context.writeString(((Text)textRep).getData()); > > + context.writeString("]]>"); > > + } else if (textRep instanceof Comment) { > > + context.writeString(""); > > + } else if (textRep instanceof Text) { > > + context.writeSafeString(((Text)textRep).getData()); > > + } > > context.setPretty(oldPretty); > > return; > > } > > @@ -1727,5 +1730,51 @@ > > if (obj == null || !(obj instanceof MessageElement)) > > return false; > > return toString().equals(obj.toString()); > > + } > > + > > + private void copyNode(org.w3c.dom.Node element) { > > + copyNode(this, element); > > + } > > + > > + private void copyNode(MessageElement parent, org.w3c.dom.Node > > element) > > + { > > + parent.setPrefix(element.getPrefix()); > > + if(element.getLocalName() != null) { > > + parent.setQName(new QName(element.getNamespaceURI(), > > element.getLocalName())); > > + } > > + > > + org.w3c.dom.NamedNodeMap attrs = element.getAttributes(); > > + for(int i = 0; i < attrs.getLength(); i++){ > > + org.w3c.dom.Node att = attrs.item(i); > > + if (att.getNamespaceURI() != null && > > + att.getPrefix() != null && > > + att.getNamespaceURI().equals(Constants.NS_URI_XMLNS) && > > + att.getPrefix().equals("xmlns")) { > > + Mapping map = new Mapping(att.getNodeValue(), > > att.getLocalName()); > > + addMapping(map); > > + } > > + parent.addAttribute(att.getPrefix(), > > + att.getNamespaceURI(), > > + att.getLocalName(), > > + att.getNodeValue()); > > + } > > + > > + org.w3c.dom.NodeList children = element.getChildNodes(); > > + for(int i = 0; i < children.getLength(); i++){ > > + org.w3c.dom.Node child = children.item(i); > > + if(child.getNodeType()==TEXT_NODE || > > + child.getNodeType()==CDATA_SECTION_NODE || > > + child.getNodeType()==COMMENT_NODE ) { > > + MessageElement childElement = new > > MessageElement((CharacterData)child); > > + parent.appendChild(childElement); > > + } else { > > + PrefixedQName qname = new > > PrefixedQName(child.getNamespaceURI(), > > + child.getLocalName(), > > + child.getPrefix()); > > + MessageElement childElement = new MessageElement(qname); > > + parent.appendChild(childElement); > > + copyNode(childElement, child); > > + } > > + } > > } > > } > > > > 1.8 +1 -1 ws-axis/java/test/wsdl/sequence/SequenceService.java > > > > Index: SequenceService.java > > =================================================================== > > RCS file: /home/cvs/ws-axis/java/test/wsdl/sequence/SequenceService.java,v > > retrieving revision 1.7 > > retrieving revision 1.8 > > diff -u -r1.7 -r1.8 > > --- SequenceService.java 25 Feb 2004 14:03:05 -0000 1.7 > > +++ SequenceService.java 24 Jun 2004 12:27:37 -0000 1.8 > > @@ -78,7 +78,7 @@ > > success = true; > > } > > > > - resultElement = retDoc.createElement("return"); > > + resultElement = retDoc.createElementNS(null,"return"); > > > > String resultStr = "false"; > > if (success) { > > > > 1.111 +3 -0 > > ws-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java > > > > Index: SerializationContextImpl.java > > =================================================================== > > RCS file: > > /home/cvs/ws-axis/java/src/org/apache/axis/encoding/SerializationContextImpl > > java,v > > retrieving revision 1.110 > > retrieving revision 1.111 > > diff -u -r1.110 -r1.111 > > --- SerializationContextImpl.java 8 Jun 2004 19:45:48 -0000 > > 1.110 > > +++ SerializationContextImpl.java 24 Jun 2004 12:27:37 -0000 > > 1.111 > > @@ -403,6 +403,9 @@ > > if (prefix == null) { > > if (defaultPrefix == null) { > > prefix = "ns" + lastPrefixIndex++; > > + while(nsStack.getNamespaceURI(prefix)!=null) { > > + prefix = "ns" + lastPrefixIndex++; > > + } > > } else { > > prefix = defaultPrefix; > > } > > > > 1.19 +3 -3 ws-axis/java/test/encoding/TestDOM.java > > > > Index: TestDOM.java > > =================================================================== > > RCS file: /home/cvs/ws-axis/java/test/encoding/TestDOM.java,v > > retrieving revision 1.18 > > retrieving revision 1.19 > > diff -u -r1.18 -r1.19 > > --- TestDOM.java 18 Nov 2003 22:36:37 -0000 1.18 > > +++ TestDOM.java 24 Jun 2004 12:27:38 -0000 1.19 > > @@ -123,14 +123,14 @@ > > > > public void testEmptyNode() throws Exception > > { > > - SOAPBodyElement body = new > > SOAPBodyElement(XMLUtils.newDocument().createElement("tmp")); > > + SOAPBodyElement body = new > > SOAPBodyElement(XMLUtils.newDocument().createElementNS(null,"tmp")); > > assertXMLEqual("",body.toString()); > > } > > > > public void testNodeWithAttribute() throws Exception > > { > > - org.w3c.dom.Element element = > > XMLUtils.newDocument().createElement("tmp"); > > - element.setAttribute("attrib", "foo"); > > + org.w3c.dom.Element element = > > XMLUtils.newDocument().createElementNS(null,"tmp"); > > + element.setAttributeNS(null,"attrib", "foo"); > > SOAPBodyElement body = new SOAPBodyElement(element); > > assertXMLEqual("",body.toString()); > > } > > > > 1.15 +75 -10 ws-axis/java/test/message/TestMessageElement.java > > > > Index: TestMessageElement.java > > =================================================================== > > RCS file: /home/cvs/ws-axis/java/test/message/TestMessageElement.java,v > > retrieving revision 1.14 > > retrieving revision 1.15 > > diff -u -r1.14 -r1.15 > > --- TestMessageElement.java 10 Apr 2004 21:12:06 -0000 1.14 > > +++ TestMessageElement.java 24 Jun 2004 12:27:38 -0000 1.15 > > @@ -16,7 +16,6 @@ > > > > package test.message; > > > > -import junit.framework.TestCase; > > import org.apache.axis.Message; > > import org.apache.axis.MessageContext; > > import org.apache.axis.client.AxisClient; > > @@ -26,30 +25,37 @@ > > import org.apache.axis.message.MessageElement; > > import org.apache.axis.message.PrefixedQName; > > import org.apache.axis.soap.SOAPConstants; > > +import org.apache.axis.utils.XMLUtils; > > +import org.w3c.dom.Document; > > +import org.w3c.dom.Element; > > +import org.w3c.dom.CDATASection; > > import org.xml.sax.Attributes; > > +import test.AxisTestBase; > > > > import javax.xml.namespace.QName; > > +import javax.xml.soap.MessageFactory; > > import javax.xml.soap.Name; > > +import javax.xml.soap.SOAPBody; > > +import javax.xml.soap.SOAPBodyElement; > > import javax.xml.soap.SOAPElement; > > -import javax.xml.soap.MessageFactory; > > +import javax.xml.soap.SOAPEnvelope; > > import javax.xml.soap.SOAPMessage; > > import javax.xml.soap.SOAPPart; > > -import javax.xml.soap.SOAPEnvelope; > > -import javax.xml.soap.SOAPBody; > > -import javax.xml.soap.SOAPBodyElement; > > -import java.util.Iterator; > > -import java.io.StringReader; > > -import java.io.ByteArrayOutputStream; > > -import java.io.ObjectOutputStream; > > +import javax.xml.parsers.DocumentBuilderFactory; > > +import javax.xml.parsers.DocumentBuilder; > > import java.io.ByteArrayInputStream; > > +import java.io.ByteArrayOutputStream; > > import java.io.ObjectInputStream; > > +import java.io.ObjectOutputStream; > > +import java.io.StringReader; > > +import java.util.Iterator; > > > > /** > > * Test MessageElement class. > > * > > * @author Glyn Normington (glyn@apache.org) > > */ > > -public class TestMessageElement extends TestCase { > > +public class TestMessageElement extends AxisTestBase { > > > > public TestMessageElement(String name) { > > super(name); > > @@ -241,6 +247,65 @@ > > > > assertEquals("m1 is not the same as m2", m1, m2); > > assertEquals("m2 is not the same as m1", m2, m1); > > + } > > + > > + public void testElementConstructor() throws Exception { > > + String xmlIn = " > + > > + " > > xmlns:h=\"http://www.w3.org/HTML/1998/html4\">\n" + > > + " Book > > Review\n" + > > + " \n" + > > + " \n" + > > + " XML: A Primer\n" + > > + " \n" + > > + " \n" + > > + " AuthorPrice\n" + > > + " > > PagesDate\n" + > > + " \n" + > > + " \n" + > > + " Simon St. > > Laurent\n" + > > + " 31.98\n" > > + > > + " 352\n" + > > + " 1998/01\n" > > + > > + " \n" + > > + " \n" + > > + " \n" + > > + " \n" + > > + " \n" + > > + ""; > > + > > + Document doc = XMLUtils.newDocument(new > > ByteArrayInputStream(xmlIn.getBytes())); > > + MessageElement me = new MessageElement(doc.getDocumentElement()); > > + String xmlOut = me.getAsString(); > > + this.assertXMLEqual(xmlIn,xmlOut); > > + } > > + > > + public void testElementConstructor2() throws Exception { > > + String xmlIn = "\n" + > > + "\n" + > > + "\n" + > > + "\n" + > > + " > xmlns:java=\"http://xml.apache.org/axis/wsdd/providers/java\" > > xmlns:ns1=\"urn:EchoAttachmentsService\" >\n" + > > + " > provider=\"java:RPC\" >\n" + > > + " > value=\"samples.attachments.EchoAttachmentsService\"/>\n" + > > + " > echoDir\"/>\n" + > > + " > returnType=\"ns1:DataHandler\" >\n" + > > + " > type=\"ns1:DataHandler\"/>\n" + > > + " \n" + > > + "\n" + > > + " > deserializer=\"org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactor > > y\"\n" + > > + " > > languageSpecificType=\"java:javax.activation.DataHandler\" > > qname=\"ns1:DataHandler\"\n" + > > + " > > serializer=\"org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory\"\ > > n" + > > + " > > encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"\n" + > > + " />\n" + > > + " \n" + > > + "\n" + > > + ""; > > + > > + Document doc = XMLUtils.newDocument(new > > ByteArrayInputStream(xmlIn.getBytes())); > > + MessageElement me = new MessageElement(doc.getDocumentElement()); > > + String xmlOut = me.getAsString(); > > + System.out.println(xmlOut); > > + this.assertXMLEqual(xmlIn,xmlOut); > > } > > > > public static void main(String[] args) throws Exception { > > > > > > > -- > Davanum Srinivas - http://webservices.apache.org/~dims/ > -- Davanum Srinivas - http://webservices.apache.org/~dims/