snichol 2002/11/26 18:36:08 Modified: java/src/org/apache/soap Envelope.java java/src/org/apache/soap/encoding/soapenc QNameSerializer.java SoapEncUtils.java java/src/org/apache/soap/server TypeMappingSerializer.java Log: Where possible, use SOAPMappingRegistry#getSchemaURI rather than Constants#NS_URI_CURRENT_SCHEMA_XSD, so that, e.g., a Call serialized using a SOAPMappingRegistry based on the 1999 schema will serialize properly. Revision Changes Path 1.14 +13 -6 xml-soap/java/src/org/apache/soap/Envelope.java Index: Envelope.java =================================================================== RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/Envelope.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- Envelope.java 18 Nov 2002 21:52:05 -0000 1.13 +++ Envelope.java 27 Nov 2002 02:36:08 -0000 1.14 @@ -102,12 +102,6 @@ // Declare the "SOAP-ENV" namespace. setAttribute(N_SOAP_ENV, Constants.NS_URI_SOAP_ENV); - - // Declare the "xsi" namespace. - setAttribute(N_SCHEMA_XSI, Constants.NS_URI_CURRENT_SCHEMA_XSI); - - // Declare the "xsd" namespace. - setAttribute(N_SCHEMA_XSD, Constants.NS_URI_CURRENT_SCHEMA_XSD); } /** @@ -223,6 +217,19 @@ throw new IllegalArgumentException("An '" + Constants.Q_ELEM_ENVELOPE + "' must contain a: '" + Constants.Q_ELEM_BODY + "'."); + } + + if (xjmr instanceof SOAPMappingRegistry) { + String schemaURI = ((SOAPMappingRegistry) xjmr).getSchemaURI(); + // Declare the "xsi" namespace. + setAttribute(N_SCHEMA_XSI, schemaURI + "-instance"); + // Declare the "xsd" namespace. + setAttribute(N_SCHEMA_XSD, schemaURI); + } else { + // Declare the "xsi" namespace. + setAttribute(N_SCHEMA_XSI, Constants.NS_URI_CURRENT_SCHEMA_XSI); + // Declare the "xsd" namespace. + setAttribute(N_SCHEMA_XSD, Constants.NS_URI_CURRENT_SCHEMA_XSD); } // Initialize the namespace stack. 1.5 +73 -4 xml-soap/java/src/org/apache/soap/encoding/soapenc/QNameSerializer.java Index: QNameSerializer.java =================================================================== RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/QNameSerializer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- QNameSerializer.java 17 May 2001 16:17:13 -0000 1.4 +++ QNameSerializer.java 27 Nov 2002 02:36:08 -0000 1.5 @@ -1,11 +1,75 @@ +/* + * The Apache Software License, Version 1.1 + * + * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "SOAP" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact [EMAIL PROTECTED] + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation and was + * originally based on software copyright (c) 2000, International + * Business Machines, Inc., http://www.apache.org. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ package org.apache.soap.encoding.soapenc; +import java.io.IOException; +import java.io.Writer; + import org.apache.soap.Constants; import org.apache.soap.util.Bean; -import org.apache.soap.util.xml.*; +import org.apache.soap.util.xml.Deserializer; +import org.apache.soap.util.xml.DOMUtils; +import org.apache.soap.util.xml.NSStack; +import org.apache.soap.util.xml.QName; +import org.apache.soap.util.xml.Serializer; +import org.apache.soap.util.xml.XMLJavaMappingRegistry; +import org.apache.soap.encoding.SOAPMappingRegistry; import org.apache.soap.rpc.SOAPContext; import org.w3c.dom.*; -import java.io.*; /** A QNameSerializer serializes a QName as follows: * <elementName xmlns:ns="QNameURIPart">ns:QNameLocalPart</elementName> @@ -26,9 +90,14 @@ QName elementType = xjmr.queryElementType(javaType, Constants.NS_URI_SOAP_ENC); - + + String schemaInstanceURI; + if (xjmr instanceof SOAPMappingRegistry) + schemaInstanceURI = ((SOAPMappingRegistry) xjmr).getSchemaURI() + "-instance"; + else + schemaInstanceURI = Constants.NS_URI_CURRENT_SCHEMA_XSI; String xsiNSPrefix = - nsStack.getPrefixFromURI(Constants.NS_URI_CURRENT_SCHEMA_XSI, sink); + nsStack.getPrefixFromURI(schemaInstanceURI, sink); String elementTypeNSPrefix = nsStack.getPrefixFromURI(elementType.getNamespaceURI(), sink); 1.19 +7 -3 xml-soap/java/src/org/apache/soap/encoding/soapenc/SoapEncUtils.java Index: SoapEncUtils.java =================================================================== RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/encoding/soapenc/SoapEncUtils.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- SoapEncUtils.java 6 Nov 2002 15:11:08 -0000 1.18 +++ SoapEncUtils.java 27 Nov 2002 02:36:08 -0000 1.19 @@ -61,6 +61,7 @@ import org.w3c.dom.*; import org.apache.soap.util.xml.*; import org.apache.soap.*; +import org.apache.soap.encoding.SOAPMappingRegistry; import org.apache.soap.rpc.SOAPContext; /** @@ -178,12 +179,15 @@ // Get prefixes for the needed namespaces. String elementTypeNS = elementType.getNamespaceURI(); - String xsiNamespaceURI = Constants.NS_URI_CURRENT_SCHEMA_XSI; + String xsiNamespaceURI; if (elementTypeNS.startsWith("http://www.w3.org/") - && elementTypeNS.endsWith("/XMLSchema")) - { + && elementTypeNS.endsWith("/XMLSchema")) { xsiNamespaceURI = elementTypeNS + "-instance"; + } else if (xjmr instanceof SOAPMappingRegistry) { + xsiNamespaceURI = ((SOAPMappingRegistry) xjmr).getSchemaURI() + "-instance"; + } else { + xsiNamespaceURI = Constants.NS_URI_CURRENT_SCHEMA_XSI; } String xsiNSPrefix = nsStack.getPrefixFromURI(xsiNamespaceURI, sink); 1.12 +14 -5 xml-soap/java/src/org/apache/soap/server/TypeMappingSerializer.java Index: TypeMappingSerializer.java =================================================================== RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/TypeMappingSerializer.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- TypeMappingSerializer.java 30 Aug 2002 21:39:01 -0000 1.11 +++ TypeMappingSerializer.java 27 Nov 2002 02:36:08 -0000 1.12 @@ -98,13 +98,22 @@ sink.write (StringUtils.lineSeparator); // these namespaces being defined by the envelope stuff - String xsiPrefix = nsStack.getPrefixFromURI (Constants.NS_URI_CURRENT_SCHEMA_XSI); - String xsdPrefix = nsStack.getPrefixFromURI (Constants.NS_URI_CURRENT_SCHEMA_XSD); + String schemaURI; + String schemaInstanceURI; + if (xjmr instanceof SOAPMappingRegistry) { + schemaURI = ((SOAPMappingRegistry) xjmr).getSchemaURI(); + schemaInstanceURI = schemaURI + "-instance"; + } else { + schemaURI = Constants.NS_URI_CURRENT_SCHEMA_XSD; + schemaInstanceURI = Constants.NS_URI_CURRENT_SCHEMA_XSI; + } + String xsiPrefix = nsStack.getPrefixFromURI(schemaInstanceURI); + String xsdPrefix = nsStack.getPrefixFromURI(schemaURI); if ((xsiPrefix == null) || (xsdPrefix == null)) { - throw new IllegalArgumentException ("required namespace names '" + - Constants.NS_URI_CURRENT_SCHEMA_XSI + + throw new IllegalArgumentException ("required namespace name for '" + + schemaInstanceURI + "' and/or '" + - Constants.NS_URI_CURRENT_SCHEMA_XSD + + schemaURI + "' is not defined."); }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>