scheu 02/01/30 19:26:09
Modified: java TODO.txt
java/samples/echo TestClient.java deploy.wsdd
java/src/javax/xml/rpc/encoding TypeMappingRegistry.java
java/src/org/apache/axis/client Call.java
java/src/org/apache/axis/deployment/wsdd WSDDService.java
WSDDTypeMapping.java
java/src/org/apache/axis/encoding
DefaultTypeMappingImpl.java
DeserializationContextImpl.java TypeMapping.java
TypeMappingImpl.java TypeMappingRegistry.java
TypeMappingRegistryImpl.java
java/src/org/apache/axis/encoding/ser ArraySerializer.java
Base64Deserializer.java
Base64DeserializerFactory.java
Base64Serializer.java Base64SerializerFactory.java
SimpleDeserializer.java
java/src/org/apache/axis/handlers/soap SOAPService.java
java/test/encoding TestDeser.java
Log:
The following changes are made for interop/encoding:
I ran all of the tests including the interop tests to verify
the quality of these changes.
1) Added the delegate() method to TypeMappingRegistry.
This provides the function of the old setParent() stuff and
is necessary to tie together service and deploy typeMappings.
2) Changed the samples.echo.TestClient to register array complexType
deserializers. Some of the services pass back
type=urn:ArrayOfFoo instead of the normal type=soapenc:Array.
So to interoperate we need to register the deserializers.
a) the deploy.wsdd and stub changes are defered.
b) A side effect is that a small change was necessary
in the array serializer to force the type to soapenc:Array.
Registering the deserializers had a bad side effect of
damaging the type attribute.
c) Also needed to change the call.registerTypeMapping() to
register the serializer/deserializer in the proper typemapping.
(This lead to the changes in 1)
3) Changed the Base64 serializers/deserializers to operate
with Byte[] (used to only work with byte[])
4) Changed soapenc:base64 to deserialize as byte[] not Byte[] so that we are
interoperable. (Some services return soapenc:base64 when passed
xsd:base64Binary)
5) Changed the defaultTypeMapping to understand how to deserialize
soapenc primitives. Added two small tests into TestDeser to verify
this behavior since we don't pass SOAP 1.2 over the wire.
Revision Changes Path
1.12 +8 -1 xml-axis/java/TODO.txt
Index: TODO.txt
===================================================================
RCS file: /home/cvs/xml-axis/java/TODO.txt,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- TODO.txt 29 Jan 2002 21:28:33 -0000 1.11
+++ TODO.txt 31 Jan 2002 03:26:08 -0000 1.12
@@ -19,7 +19,7 @@
JAX-RPC COMPATIBILITY
---------------------
-* <Rich> Implement serializer/deserializer framework compliance
+X <Rich> Implement serializer/deserializer framework compliance
PERFORMANCE
-----------
@@ -75,6 +75,11 @@
! <> Need to handle collections of objects (max occurs > 1).
+! <> Need to register array types and enum types in the stub and deploy.wsdd.
+ Registering array types if the remote (non-AXIS) services sets the
+ type attribute to the array type name instead of soapenc:array.
+ See samples.echo.testClient
+
Java2WSDL
---------
X <> Plug new framework into autogen mechanism
@@ -91,6 +96,8 @@
</wsdl:message>
! <> Support generating schema for custom serializers
+
+! <> Support generation of deploy.wsdd from Java2WSDL
GENERAL / UNCATEGORIZED
1.46 +19 -1 xml-axis/java/samples/echo/TestClient.java
Index: TestClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/echo/TestClient.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- TestClient.java 26 Jan 2002 02:52:38 -0000 1.45
+++ TestClient.java 31 Jan 2002 03:26:08 -0000 1.46
@@ -60,6 +60,8 @@
import org.apache.axis.client.Service;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
+import org.apache.axis.encoding.ser.ArraySerializerFactory;
+import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
import org.apache.axis.encoding.TypeMappingRegistry;
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.Constants;
@@ -199,7 +201,6 @@
call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(url) );
tmr = call.getMessageContext().getTypeMappingRegistry();
- tm = (TypeMapping) tmr.getTypeMapping(Constants.URI_SOAP_ENC);
}
catch( Exception exp ) {
throw AxisFault.makeFault(exp);
@@ -215,6 +216,23 @@
Class cls = SOAPStruct.class;
call.registerTypeMapping(cls, ssqn, BeanSerializerFactory.class,
BeanDeserializerFactory.class);
+ // Register deserializer factories for the array types.
+ // AXIS doesn't use the array types during serialization,
+ // so there is no need to register the serializer factories.
+ QName q = new QName("http://soapinterop.org/xsd", "ArrayOfSOAPStruct");
+ Class c = SOAPStruct[].class;
+ call.registerTypeMapping(c,q, null, ArrayDeserializerFactory.class);
+ q = new QName("http://soapinterop.org/xsd", "ArrayOfstring");
+ c = java.lang.String[].class;
+ call.registerTypeMapping(c,q, null, ArrayDeserializerFactory.class);
+ q = new QName("http://soapinterop.org/xsd", "ArrayOffloat");
+ c = float[].class;
+ call.registerTypeMapping(c,q, null, ArrayDeserializerFactory.class);
+ q = new QName("http://soapinterop.org/xsd", "ArrayOfint");
+ c = int[].class;
+ call.registerTypeMapping(c,q, null, ArrayDeserializerFactory.class);
+ tm = (TypeMapping) tmr.getTypeMapping(Constants.URI_SOAP_ENC);
+
// execute the tests
test("String ", "abcdefg");
test("StringArray ", new String[] {"abc", "def"});
1.10 +1 -0 xml-axis/java/samples/echo/deploy.wsdd
Index: deploy.wsdd
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/echo/deploy.wsdd,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- deploy.wsdd 29 Jan 2002 05:43:10 -0000 1.9
+++ deploy.wsdd 31 Jan 2002 03:26:08 -0000 1.10
@@ -14,5 +14,6 @@
<parameter name="allowedMethods" value="*" />
<beanMapping xmlns:echo="http://soapinterop.org/xsd" qname="echo:SOAPStruct"
languageSpecificType="java:samples.echo.SOAPStruct"/>
+
</service>
</deployment>
1.9 +6 -0
xml-axis/java/src/javax/xml/rpc/encoding/TypeMappingRegistry.java
Index: TypeMappingRegistry.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/javax/xml/rpc/encoding/TypeMappingRegistry.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- TypeMappingRegistry.java 26 Jan 2002 02:50:51 -0000 1.8
+++ TypeMappingRegistry.java 31 Jan 2002 03:26:08 -0000 1.9
@@ -132,6 +132,12 @@
*/
public void clear(String namespaceURI);
+ /**
+ * Return the default TypeMapping
+ * @return TypeMapping or null
+ **/
+ public javax.xml.rpc.encoding.TypeMapping getDefaultTypeMapping();
+
}
1.65 +3 -1 xml-axis/java/src/org/apache/axis/client/Call.java
Index: Call.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- Call.java 26 Jan 2002 02:50:51 -0000 1.64
+++ Call.java 31 Jan 2002 03:26:08 -0000 1.65
@@ -1091,9 +1091,11 @@
// If a TypeMapping is not available, add one.
TypeMapping tm = (TypeMapping)
tmr.getTypeMapping(Constants.URI_CURRENT_SOAP_ENC);
+ TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping();
try {
- if (tm == null) {
+ if (tm == null || tm == defaultTM ) {
tm = (TypeMapping) tmr.createTypeMapping();
+ tm.setSupportedEncodings(new String[]
{Constants.URI_CURRENT_SOAP_ENC});
tmr.register(tm, new String[] {Constants.URI_CURRENT_SOAP_ENC});
}
if (!force && tm.getClassForQName(xmlType) != null)
1.34 +9 -0
xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java
Index: WSDDService.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- WSDDService.java 29 Jan 2002 11:23:48 -0000 1.33
+++ WSDDService.java 31 Jan 2002 03:26:08 -0000 1.34
@@ -84,6 +84,7 @@
public TypeMappingRegistry tmr = null;
private Vector faultFlows = new Vector();
+ private Vector typeMappings = new Vector();
private String descriptionURL;
@@ -241,7 +242,11 @@
service.setName(getQName().getLocalPart());
service.setOptions(getParametersTable());
+ if (tmr == null) {
+ tmr = new TypeMappingRegistryImpl();
+ }
service.setTypeMappingRegistry(tmr);
+ tmr.delegate(registry.getTypeMappingRegistry());
WSDDFaultFlow [] faultFlows = getFaultFlows();
if (faultFlows != null && faultFlows.length > 0) {
@@ -302,6 +307,7 @@
mapping.getQName());
}
tm.register( mapping.getLanguageSpecificType(), mapping.getQName(),
ser, deser);
+ typeMappings.add(mapping);
} catch (ClassNotFoundException e) {
throw new WSDDException(e);
} catch (Exception e) {
@@ -330,6 +336,9 @@
writeParamsToContext(context);
if (tmr != null) {
+ for (int i=0; i < typeMappings.size(); i++) {
+ ((WSDDTypeMapping)
typeMappings.elementAt(i)).writeToContext(context);
+ }
// RJS_TEMP
// Need to provide a writeTypeMappingsToContext
//tmr.dumpToSerializationContext(context);
1.19 +1 -1
xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTypeMapping.java
Index: WSDDTypeMapping.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTypeMapping.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- WSDDTypeMapping.java 30 Jan 2002 03:34:09 -0000 1.18
+++ WSDDTypeMapping.java 31 Jan 2002 03:26:08 -0000 1.19
@@ -74,7 +74,7 @@
extends WSDDElement
{
protected QName qname = null;
- protected String serializer = null;
+ protected String serializer = null;
protected String deserializer = null;
protected QName typeQName = null;
protected String ref = null;
1.5 +98 -60
xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
Index: DefaultTypeMappingImpl.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultTypeMappingImpl.java 29 Jan 2002 22:34:04 -0000 1.4
+++ DefaultTypeMappingImpl.java 31 Jan 2002 03:26:09 -0000 1.5
@@ -122,20 +122,91 @@
private DefaultTypeMappingImpl() {
super(null);
- delegateIfNotFound = false;
+ delegate = null;
+
+ // Notes:
+ // 1) If the soap11Ser flag is set, then the SOAP 1.1 format is sent
+ // over the wire. Otherwise SOAP 1.2 format is used over the wire.
+ // 2) The registration statements are order dependent. The last one
+ // wins. So if two javaTypes of String are registered, the serializer
+ // factory for the last one registered will be chosen. Likewise
+ // if two javaTypes for XSD_DATE are registered, the deserializer
+ // factory for the last one registered will be chosen.
+ // 3) Even if the SOAP 1.1 format is used over the wire, an
+ // attempt is made to receive SOAP 1.2 format from the wire.
+ // This is the reason why the soap encoded primitives are
+ // registered without serializers.
+ boolean soap11Ser =
Constants.URI_CURRENT_SOAP_ENC.equals(Constants.URI_SOAP_ENC);
+
+ // SOAP Encoded strings are treated as primitives. Everything else is not.
+ // Note that only deserializing is supported if we are flowing SOAP 1.1
over the wire
+ myRegister(Constants.SOAP_STRING, java.lang.String.class, null,
null, true, soap11Ser);
+ myRegister(Constants.SOAP_BOOLEAN, java.lang.Boolean.class, null,
null, false, soap11Ser);
+ myRegister(Constants.SOAP_DOUBLE, java.lang.Double.class, null,
null, false, soap11Ser);
+ myRegister(Constants.SOAP_FLOAT, java.lang.Float.class, null,
null, false, soap11Ser);
+ myRegister(Constants.SOAP_INT, java.lang.Integer.class, null,
null, false, soap11Ser);
+ myRegister(Constants.SOAP_INTEGER, java.math.BigInteger.class, null,
null, false, soap11Ser);
+ myRegister(Constants.SOAP_DECIMAL, java.math.BigDecimal.class, null,
null, false, soap11Ser);
+ myRegister(Constants.SOAP_LONG, java.lang.Long.class, null,
null, false, soap11Ser);
+ myRegister(Constants.SOAP_SHORT, java.lang.Short.class, null,
null, false, soap11Ser);
+ myRegister(Constants.SOAP_BYTE, java.lang.Byte.class, null,
null, false, soap11Ser);
+
+
+ // SOAP 1.1
+ // byte[] -ser-> XSD_BASE64
+ // Byte[] -ser-> array of Byte
+ // XSD_BASE64 -deser-> byte[]
+ // SOAP_BASE64 -deser->byte[]
+ //
+ // SOAP 1.2
+ // byte[] -ser-> XSD_BASE64
+ // Byte[] -ser-> SOAP_BASE64
+ // XSD_BASE64 -deser-> byte[]
+ // SOAP_BASE64 -deser->Byte[]
+ if (soap11Ser) {
+ myRegister(Constants.SOAP_BASE64, byte[].class,
+ new
Base64SerializerFactory(byte[].class,Constants.SOAP_BASE64 ),
+ new
Base64DeserializerFactory(byte[].class,Constants.SOAP_BASE64),
+ true, true);
+ myRegister(Constants.SOAP_ARRAY, java.lang.Byte[].class,
+ new ArraySerializerFactory(),
+ new ArrayDeserializerFactory(),true);
+ } else {
+ myRegister(Constants.SOAP_BASE64, java.lang.Byte[].class,
+ new
Base64SerializerFactory(java.lang.Byte[].class,Constants.SOAP_BASE64 ),
+ new Base64DeserializerFactory(java.lang.Byte[].class,
Constants.SOAP_BASE64),
+ true);
+ }
+ myRegister(Constants.XSD_BASE64, byte[].class,
+ new Base64SerializerFactory(byte[].class,Constants.XSD_BASE64 ),
+ new
Base64DeserializerFactory(byte[].class,Constants.XSD_BASE64),true);
+
+
+ if (soap11Ser) {
+ // If SOAP 1.1 over the wire, then map wrapper classes to XSD
primitives.
+ // Even though the java class is an object, since these are all
+ // xsd primitives, treat them as a primitive.
+ myRegister(Constants.XSD_STRING, java.lang.String.class, null,
null, true);
+ myRegister(Constants.XSD_BOOLEAN, java.lang.Boolean.class, null,
null, true);
+ myRegister(Constants.XSD_DOUBLE, java.lang.Double.class, null,
null, true);
+ myRegister(Constants.XSD_FLOAT, java.lang.Float.class, null,
null, true);
+ myRegister(Constants.XSD_INT, java.lang.Integer.class, null,
null, true);
+ myRegister(Constants.XSD_INTEGER, java.math.BigInteger.class, null,
null, true);
+ myRegister(Constants.XSD_DECIMAL, java.math.BigDecimal.class, null,
null, true);
+ myRegister(Constants.XSD_LONG, java.lang.Long.class, null,
null, true);
+ myRegister(Constants.XSD_SHORT, java.lang.Short.class, null,
null, true);
+ myRegister(Constants.XSD_BYTE, java.lang.Byte.class, null,
null, true);
+ }
// The XSD Primitives are mapped to java primitives.
- // The corresponding SOAP-ENC primitives are mapped to the wrapper classes.
- myRegister(Constants.XSD_BOOLEAN, boolean.class, null,
null, true);
+ myRegister(Constants.XSD_BOOLEAN, boolean.class, null,
null,true);
myRegister(Constants.XSD_DOUBLE, double.class, null,
null,true);
myRegister(Constants.XSD_FLOAT, float.class, null,
null,true);
myRegister(Constants.XSD_INT, int.class, null,
null,true);
myRegister(Constants.XSD_LONG, long.class, null,
null,true);
myRegister(Constants.XSD_SHORT, short.class, null,
null,true);
myRegister(Constants.XSD_BYTE, byte.class, null,
null,true);
- myRegister(Constants.XSD_STRING, java.lang.String.class, null,
null,true);
- myRegister(Constants.XSD_INTEGER, java.math.BigInteger.class, null,
null,true);
- myRegister(Constants.XSD_DECIMAL, java.math.BigDecimal.class, null,
null,true);
+
myRegister(Constants.XSD_QNAME, javax.xml.rpc.namespace.QName.class,
new BeanSerializerFactory(javax.xml.rpc.namespace.QName.class,
Constants.XSD_QNAME),
@@ -154,10 +225,6 @@
myRegister(Constants.XSD_DATE, java.util.Date.class,
new
DateSerializerFactory(java.util.Date.class,Constants.XSD_DATE),
new
DateDeserializerFactory(java.util.Date.class,Constants.XSD_DATE),true);
-
- myRegister(Constants.XSD_BASE64, byte[].class,
- new Base64SerializerFactory(),
- new Base64DeserializerFactory(),true);
myRegister(Constants.XSD_HEXBIN, Hex.class,
new HexSerializerFactory(),
new HexDeserializerFactory(),true);
@@ -189,70 +256,41 @@
myRegister(Constants.SOAP_ARRAY, java.util.ArrayList.class,
new ArraySerializerFactory(),
new ArrayDeserializerFactory(), false);
-
- // Register the SOAP Primitives if we SOAP 1.2 over the wire.
- // (Currently URI_CURRENT_SOAP_ENC is set to SOAP 1.1)
- if (Constants.URI_CURRENT_SOAP_ENC.equals(Constants.URI_SOAP12_ENC)) {
- // SOAP Encoded strings are treated as primitives. Everything else is
not.
- myRegister(Constants.SOAP_STRING, java.lang.String.class, null,
null, true);
- myRegister(Constants.SOAP_BOOLEAN, java.lang.Boolean.class, null,
null, false);
- myRegister(Constants.SOAP_DOUBLE, java.lang.Double.class, null,
null, false);
- myRegister(Constants.SOAP_FLOAT, java.lang.Float.class, null,
null, false);
- myRegister(Constants.SOAP_INT, java.lang.Integer.class, null,
null, false);
- myRegister(Constants.SOAP_INTEGER, java.math.BigInteger.class, null,
null, false);
- myRegister(Constants.SOAP_DECIMAL, java.math.BigDecimal.class, null,
null, false);
- myRegister(Constants.SOAP_LONG, java.lang.Long.class, null,
null, false);
- myRegister(Constants.SOAP_SHORT, java.lang.Short.class, null,
null, false);
- myRegister(Constants.SOAP_BYTE, java.lang.Byte.class, null,
null, false);
- // Note that a SOAP_BASE64 is mapped to a Byte[] not a byte[]. This is
- // the reason why the array serialization is used.
- myRegister(Constants.SOAP_BASE64, java.lang.Byte[].class,
- new ArraySerializerFactory(),
- new ArrayDeserializerFactory(),true);
-
- } else {
- // Even though the java class is an object, since these are all
- // xsd primitives, treat them as a primitive.
- myRegister(Constants.XSD_STRING, java.lang.String.class, null,
null, true);
- myRegister(Constants.XSD_BOOLEAN, java.lang.Boolean.class, null,
null, true);
- myRegister(Constants.XSD_DOUBLE, java.lang.Double.class, null,
null, true);
- myRegister(Constants.XSD_FLOAT, java.lang.Float.class, null,
null, true);
- myRegister(Constants.XSD_INT, java.lang.Integer.class, null,
null, true);
- myRegister(Constants.XSD_INTEGER, java.math.BigInteger.class, null,
null, true);
- myRegister(Constants.XSD_DECIMAL, java.math.BigDecimal.class, null,
null, true);
- myRegister(Constants.XSD_LONG, java.lang.Long.class, null,
null, true);
- myRegister(Constants.XSD_SHORT, java.lang.Short.class, null,
null, true);
- myRegister(Constants.XSD_BYTE, java.lang.Byte.class, null,
null, true);
-
- // Need to accept a SOAP_BASE64 over the wire...which maps to byte[].
- // Note that this is serialized over the wire as XSD_BASE64.
- myRegister(Constants.SOAP_BASE64, byte[].class,
- null,
- new Base64DeserializerFactory(),true);
- myRegister(Constants.XSD_BASE64, byte[].class,
- new Base64SerializerFactory(),
- new Base64DeserializerFactory(),true);
- }
-
}
/**
* Construct TypeMapping for all the [xmlType, javaType] for all of the
* known xmlType namespaces
+ * @param xmlType is the QName type
+ * @param javaType is the java type
+ * @param sf is the serializer factory (if null, the simple factory is used)
+ * @param df is the deserializer factory (if null, the simple factory is used)
+ * @param primitive indicates whether the item is a primitive (allows for
sharing of serializers)
+ * @param onlyDeserFactory indicates if only deserialization is desired.
*/
protected void myRegister(QName xmlType, Class javaType,
SerializerFactory sf, DeserializerFactory df, boolean
primitive) {
+ myRegister(xmlType, javaType, sf, df, primitive, false);
+ }
+ protected void myRegister(QName xmlType, Class javaType,
+ SerializerFactory sf, DeserializerFactory df,
+ boolean primitive, boolean onlyDeserFactory) {
// If factories are not specified, use the Simple serializer/deserializer
factories.
if (sf == null && df == null) {
- if (primitive) {
- sf = new SimplePrimitiveSerializerFactory(javaType, xmlType);
- } else {
- sf = new SimpleNonPrimitiveSerializerFactory(javaType, xmlType);
+ if (!onlyDeserFactory) {
+ if (primitive) {
+ sf = new SimplePrimitiveSerializerFactory(javaType, xmlType);
+ } else {
+ sf = new SimpleNonPrimitiveSerializerFactory(javaType, xmlType);
+ }
}
df = new SimpleDeserializerFactory(javaType, xmlType);
}
-
+ if (onlyDeserFactory) {
+ sf = null;
+ }
+
// Register all known flavors of the namespace.
try {
if (xmlType.getNamespaceURI().equals(Constants.URI_CURRENT_SCHEMA_XSD))
{
1.4 +8 -8
xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java
Index: DeserializationContextImpl.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DeserializationContextImpl.java 28 Jan 2002 23:05:41 -0000 1.3
+++ DeserializationContextImpl.java 31 Jan 2002 03:26:09 -0000 1.4
@@ -327,21 +327,21 @@
} else if (myQName.equals(Constants.SOAP_ARRAY)) {
typeQName = Constants.SOAP_ARRAY;
} else if (myQName.equals(Constants.SOAP_STRING)) {
- typeQName = Constants.XSD_STRING;
+ typeQName = Constants.SOAP_STRING;
} else if (myQName.equals(Constants.SOAP_BOOLEAN)) {
- typeQName = Constants.XSD_BOOLEAN;
+ typeQName = Constants.SOAP_BOOLEAN;
} else if (myQName.equals(Constants.SOAP_DOUBLE)) {
- typeQName = Constants.XSD_DOUBLE;
+ typeQName = Constants.SOAP_DOUBLE;
} else if (myQName.equals(Constants.SOAP_FLOAT)) {
- typeQName = Constants.XSD_FLOAT;
+ typeQName = Constants.SOAP_FLOAT;
} else if (myQName.equals(Constants.SOAP_INT)) {
- typeQName = Constants.XSD_INT;
+ typeQName = Constants.SOAP_INT;
} else if (myQName.equals(Constants.SOAP_LONG)) {
- typeQName = Constants.XSD_LONG;
+ typeQName = Constants.SOAP_LONG;
} else if (myQName.equals(Constants.SOAP_SHORT)) {
- typeQName = Constants.XSD_SHORT;
+ typeQName = Constants.SOAP_SHORT;
} else if (myQName.equals(Constants.SOAP_BYTE)) {
- typeQName = Constants.XSD_BYTE;
+ typeQName = Constants.SOAP_BYTE;
}
}
1.2 +5 -0 xml-axis/java/src/org/apache/axis/encoding/TypeMapping.java
Index: TypeMapping.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMapping.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TypeMapping.java 26 Jan 2002 02:40:33 -0000 1.1
+++ TypeMapping.java 31 Jan 2002 03:26:09 -0000 1.2
@@ -69,6 +69,11 @@
public interface TypeMapping extends javax.xml.rpc.encoding.TypeMapping {
/**
+ * setDelegate sets the new Delegate TypeMapping
+ */
+ public void setDelegate(TypeMapping delegate);
+
+ /**
* Gets the SerializerFactory registered for the specified pair
* of Java type and XML data type.
*
1.3 +20 -27 xml-axis/java/src/org/apache/axis/encoding/TypeMappingImpl.java
Index: TypeMappingImpl.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TypeMappingImpl.java 28 Jan 2002 17:25:39 -0000 1.2
+++ TypeMappingImpl.java 31 Jan 2002 03:26:09 -0000 1.3
@@ -82,7 +82,7 @@
* Because every web service uses the soap, schema, wsdl primitives, we could
* pre-populate the TypeMapping with these standard tuples. Instead, if requested
* namespace/class matches is not found in the TypeMapping but matches one these
- * known primitives, the request is delegated to the Default TypeMapping.
+ * known primitives, the request is delegated to the Default TypeMapping or another
TypeMapping
*
*/
public class TypeMappingImpl implements TypeMapping {
@@ -107,23 +107,28 @@
private HashMap class2Pair; // Class Name to Pair Mapping
private HashMap pair2SF; // Pair to Serialization Factory
private HashMap pair2DF; // Pair to Deserialization Factory
- private TypeMappingRegistry tmr; // Back pointer to owning TMR
- protected boolean delegateIfNotFound; // Indicates to delegate to Default if
not found
+ protected TypeMapping delegate; // Pointer to delegate or null
private ArrayList namespaces; // Supported namespaces
/**
* Construct TypeMapping
*/
- public TypeMappingImpl(TypeMappingRegistry tmr) {
- this.tmr = tmr;
+ public TypeMappingImpl(TypeMapping delegate) {
qName2Pair = new HashMap();
class2Pair = new HashMap();
pair2SF = new HashMap();
pair2DF = new HashMap();
- delegateIfNotFound = true;
+ this.delegate = delegate;
namespaces = new ArrayList();
}
-
+
+ /**
+ * setDelegate sets the new Delegate TypeMapping
+ */
+ public void setDelegate(TypeMapping delegate) {
+ this.delegate = delegate;
+ }
+
/********* JAX-RPC Compliant Method Definitions *****************/
/**
@@ -227,11 +232,8 @@
}
}
}
- if (sf == null && delegateIfNotFound) {
- TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping();
- if (defaultTM != null) {
- sf = (SerializerFactory) defaultTM.getSerializer(javaType, xmlType);
- }
+ if (sf == null && delegate != null) {
+ sf = (SerializerFactory) delegate.getSerializer(javaType, xmlType);
}
return sf;
}
@@ -264,11 +266,8 @@
if (pair.javaType != null) {
df = (DeserializerFactory) pair2DF.get(pair);
}
- if (df == null && delegateIfNotFound) {
- TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping();
- if (defaultTM != null) {
- df = (DeserializerFactory) defaultTM.getDeserializer(javaType,
xmlType);
- }
+ if (df == null && delegate != null) {
+ df = (DeserializerFactory) delegate.getDeserializer(javaType, xmlType);
}
return df;
}
@@ -321,11 +320,8 @@
//System.out.println("getTypeQName javaType =" + javaType);
QName xmlType = null;
Pair pair = (Pair) class2Pair.get(javaType);
- if (pair == null && delegateIfNotFound) {
- TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping();
- if (defaultTM != null) {
- xmlType = defaultTM.getTypeQName(javaType);
- }
+ if (pair == null && delegate != null) {
+ xmlType = delegate.getTypeQName(javaType);
} else if (pair != null) {
xmlType = pair.xmlType;
}
@@ -343,11 +339,8 @@
//System.out.println("getClassForQName xmlType =" + xmlType);
Class javaType = null;
Pair pair = (Pair) qName2Pair.get(xmlType);
- if (pair == null && delegateIfNotFound) {
- TypeMapping defaultTM = (TypeMapping) tmr.getDefaultTypeMapping();
- if (defaultTM != null) {
- javaType = defaultTM.getClassForQName(xmlType);
- }
+ if (pair == null && delegate != null) {
+ javaType = delegate.getClassForQName(xmlType);
} else if (pair != null) {
javaType = pair.javaType;
}
1.49 +6 -5
xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java
Index: TypeMappingRegistry.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- TypeMappingRegistry.java 26 Jan 2002 02:40:33 -0000 1.48
+++ TypeMappingRegistry.java 31 Jan 2002 03:26:09 -0000 1.49
@@ -61,11 +61,12 @@
*/
public interface TypeMappingRegistry extends
javax.xml.rpc.encoding.TypeMappingRegistry {
/**
- * Return the default TypeMapping
- * (According to the JAX-RPC rep, this will be in
javax.xml.rpc.encoding.TypeMappingRegistry for version 0.7)
- * @return TypeMapping or null
- **/
- public javax.xml.rpc.encoding.TypeMapping getDefaultTypeMapping();
+ * delegate
+ *
+ * Changes the contained type mappings to delegate to
+ * their corresponding types in the secondary TMR.
+ */
+ public void delegate(TypeMappingRegistry secondaryTMR);
}
1.4 +51 -44
xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistryImpl.java
Index: TypeMappingRegistryImpl.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistryImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TypeMappingRegistryImpl.java 29 Jan 2002 11:23:48 -0000 1.3
+++ TypeMappingRegistryImpl.java 31 Jan 2002 03:26:09 -0000 1.4
@@ -86,6 +86,44 @@
defaultTM = DefaultTypeMappingImpl.create();
}
+ /**
+ * delegate
+ *
+ * Changes the contained type mappings to delegate to
+ * their corresponding types in the secondary TMR.
+ */
+ public void delegate(TypeMappingRegistry secondaryTMR) {
+ if (secondaryTMR != null && secondaryTMR != this) {
+ if (defaultTM != null) {
+ defaultTM = (TypeMapping) secondaryTMR.getDefaultTypeMapping();
+ }
+ }
+ String[] keys = secondaryTMR.getSupportedNamespaces();
+ if (keys != null) {
+ for(int i=0; i < keys.length; i++) {
+ try {
+ String nsURI = keys[i];
+ TypeMapping tm = (TypeMapping) mapTM.get(nsURI);
+ if (tm == null) {
+ tm = (TypeMapping) createTypeMapping();
+ tm.setSupportedEncodings(new String[] { nsURI });
+ mapTM.put(nsURI, tm);
+ }
+
+ if (tm != null) {
+ TypeMapping del = (TypeMapping)
secondaryTMR.getTypeMapping(nsURI);
+ tm.setDelegate(del);
+ }
+
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ }
+
+
+
/********* JAX-RPC Compliant Method Definitions *****************/
/**
@@ -162,7 +200,7 @@
* @return An empty generic TypeMapping object
*/
public javax.xml.rpc.encoding.TypeMapping createTypeMapping() {
- return new TypeMappingImpl(this);
+ return new TypeMappingImpl(defaultTM);
}
@@ -172,8 +210,18 @@
* @return String[] containing names of all registered namespace URIs
*/
public String[] getSupportedNamespaces() {
- return (String[]) mapTM.keySet().toArray();
- }
+ java.util.Set s = mapTM.keySet();
+ if (s != null) {
+ String[] rc = new String[s.size()];
+ int i = 0;
+ java.util.Iterator it = s.iterator();
+ while(it.hasNext()) {
+ rc[i++] = (String) it.next();
+ }
+ return rc;
+ }
+ return null;
+ }
/**
@@ -193,45 +241,4 @@
return defaultTM;
}
-
- // This code is no longer valid. If this information should
- // be serialized, the WSDD should do it. Not the TypeMappingRegistry.
- /*
- public void dumpToElement(Element root)
- {
- if ((d == null) || (parent == null)) {
- return;
- }
-
- Document doc = root.getOwnerDocument();
-
- Enumeration enum = d.keys();
- while (enum.hasMoreElements()) {
- QName typeQName = (QName)enum.nextElement();
- DeserializerDescriptor desc =
- (DeserializerDescriptor)d.get(typeQName);
- if (desc.cls == null)
- continue;
-
- Element mapEl = doc.createElementNS("", "typeMapping");
-
- mapEl.setAttribute("type", "ns:" + typeQName.getLocalPart());
- mapEl.setAttribute("xmlns:ns", typeQName.getNamespaceURI());
-
- mapEl.setAttribute("classname", desc.cls.getName());
-
- String dser = desc.factory.getClass().getName();
- mapEl.setAttribute("deserializerFactory", dser);
-
- SerializerDescriptor serDesc =
- (SerializerDescriptor)s.get(desc.cls);
- if (serDesc != null) {
- mapEl.setAttribute("serializer", serDesc.serializer.
- getClass().getName());
- }
-
- root.appendChild(mapEl);
- }
- }
- */
}
1.2 +10 -0
xml-axis/java/src/org/apache/axis/encoding/ser/ArraySerializer.java
Index: ArraySerializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/ArraySerializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ArraySerializer.java 26 Jan 2002 02:40:34 -0000 1.1
+++ ArraySerializer.java 31 Jan 2002 03:26:09 -0000 1.2
@@ -223,6 +223,16 @@
arrayType);
attrs = attrImpl;
}
+
+ // Force type to be SOAP_ARRAY for all array serialization.
+ int typeI = attributes.getIndex(Constants.URI_CURRENT_SCHEMA_XSI,
+ "type");
+ if (typeI != -1) {
+ AttributesImpl attrImpl = new AttributesImpl(attrs);
+ attrImpl.removeAttribute(typeI);
+ attrs = context.setTypeAttribute(attrImpl, Constants.SOAP_ARRAY);
+ }
+
context.startElement(name, attrs);
1.2 +22 -1
xml-axis/java/src/org/apache/axis/encoding/ser/Base64Deserializer.java
Index: Base64Deserializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/Base64Deserializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Base64Deserializer.java 26 Jan 2002 02:40:34 -0000 1.1
+++ Base64Deserializer.java 31 Jan 2002 03:26:09 -0000 1.2
@@ -79,6 +79,13 @@
*/
public class Base64Deserializer extends DeserializerImpl implements Deserializer {
+ public QName xmlType;
+ public Class javaType;
+ public Base64Deserializer(Class javaType, QName xmlType) {
+ this.xmlType = xmlType;
+ this.javaType = javaType;
+ }
+
/**
* Handle any characters found in the data
*/
@@ -86,6 +93,14 @@
throws SAXException
{
value = Base64.decode(chars, start, end);
+ if (javaType == Byte[].class) {
+ Byte[] data = new Byte[ ((byte[])value).length ];
+ for (int i=0; i<data.length; i++) {
+ byte b = ((byte[]) value)[i];
+ data[i] = new Byte(b);
+ }
+ value = data;
+ }
}
/**
@@ -96,6 +111,12 @@
throws SAXException
{
super.onEndElement(namespace,localName, context);
- if (value == null) value = new byte[0];
+ if (value == null) {
+ if (javaType == byte[].class) {
+ value = new byte[0];
+ } else {
+ value = new Byte[0];
+ }
+ }
}
}
1.2 +2 -2
xml-axis/java/src/org/apache/axis/encoding/ser/Base64DeserializerFactory.java
Index: Base64DeserializerFactory.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/Base64DeserializerFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Base64DeserializerFactory.java 26 Jan 2002 02:40:34 -0000 1.1
+++ Base64DeserializerFactory.java 31 Jan 2002 03:26:09 -0000 1.2
@@ -74,7 +74,7 @@
* @author Rich Scheuerle <[EMAIL PROTECTED]>
*/
public class Base64DeserializerFactory extends BaseDeserializerFactory {
- public Base64DeserializerFactory() {
- super(Base64Deserializer.class, false); // Can't share deserializers
+ public Base64DeserializerFactory(Class javaType, QName xmlType) {
+ super(Base64Deserializer.class, false, xmlType, javaType); // Can't share
deserializers
}
}
1.2 +19 -2
xml-axis/java/src/org/apache/axis/encoding/ser/Base64Serializer.java
Index: Base64Serializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/Base64Serializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Base64Serializer.java 26 Jan 2002 02:40:34 -0000 1.1
+++ Base64Serializer.java 31 Jan 2002 03:26:09 -0000 1.2
@@ -80,6 +80,13 @@
*/
public class Base64Serializer implements Serializer {
+ public QName xmlType;
+ public Class javaType;
+ public Base64Serializer(Class javaType, QName xmlType) {
+ this.xmlType = xmlType;
+ this.javaType = javaType;
+ }
+
/**
* Serialize a base64 quantity.
*/
@@ -87,8 +94,18 @@
Object value, SerializationContext context)
throws IOException
{
- byte[] data = (byte[]) value;
-
+ byte[] data = null;
+ if (javaType == byte[].class) {
+ data = (byte[]) value;
+ } else {
+ data = new byte[ ((Byte[]) value).length ];
+ for (int i=0; i<data.length; i++) {
+ Byte b = ((Byte[]) value)[i];
+ if (b != null)
+ data[i] = b.byteValue();
+ }
+ }
+
context.startElement(name, attributes);
context.writeString(Base64.encode(data, 0, data.length));
context.endElement();
1.2 +3 -3
xml-axis/java/src/org/apache/axis/encoding/ser/Base64SerializerFactory.java
Index: Base64SerializerFactory.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/Base64SerializerFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Base64SerializerFactory.java 26 Jan 2002 02:40:34 -0000 1.1
+++ Base64SerializerFactory.java 31 Jan 2002 03:26:09 -0000 1.2
@@ -74,7 +74,7 @@
* @author Rich Scheuerle <[EMAIL PROTECTED]>
*/
public class Base64SerializerFactory extends BaseSerializerFactory {
- public Base64SerializerFactory() {
- super(Base64Serializer.class, true); // Share Base64Serializer instance
- }
+ public Base64SerializerFactory(Class javaType, QName xmlType) {
+ super(Base64Serializer.class, true, xmlType, javaType); // Share
Base64Serializer instance
+ }
}
1.2 +4 -0
xml-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializer.java
Index: SimpleDeserializer.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SimpleDeserializer.java 26 Jan 2002 02:40:34 -0000 1.1
+++ SimpleDeserializer.java 31 Jan 2002 03:26:09 -0000 1.2
@@ -143,6 +143,10 @@
DeserializationContext context)
throws SAXException
{
+ if (isNil) {
+ value = null;
+ return;
+ }
try {
value = makeValue(val.toString());
} catch (InvocationTargetException ite) {
1.44 +2 -1 xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java
Index: SOAPService.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- SOAPService.java 26 Jan 2002 02:50:52 -0000 1.43
+++ SOAPService.java 31 Jan 2002 03:26:09 -0000 1.44
@@ -66,6 +66,7 @@
import org.apache.axis.encoding.DeserializerFactory;
import org.apache.axis.encoding.Serializer;
import org.apache.axis.encoding.TypeMappingRegistry;
+import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.encoding.TypeMappingRegistryImpl;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPHeader;
@@ -218,7 +219,7 @@
*/
public void setEngine(AxisEngine engine)
{
- tmr = engine.getTypeMappingRegistry();
+ tmr.delegate(engine.getTypeMappingRegistry());
}
/**
1.23 +10 -0 xml-axis/java/test/encoding/TestDeser.java
Index: TestDeser.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/encoding/TestDeser.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- TestDeser.java 28 Jan 2002 18:23:03 -0000 1.22
+++ TestDeser.java 31 Jan 2002 03:26:09 -0000 1.23
@@ -270,6 +270,16 @@
public void testUntyped() throws Exception {
deserialize("<result>10</result>", "10");
}
+
+ public void testSOAPString() throws Exception {
+ deserialize("<result xsi:type=\"soapenc:string\">abc</result>",
+ "abc");
+ }
+
+ public void testNilSOAPBoolean() throws Exception {
+ deserialize("<result xsi:type=\"soapenc:boolean\" xsi:nil=\"true\" />",
+ null);
+ }
public static void main(String [] args) throws Exception
{