You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ow...@apache.org on 2002/08/06 11:48:17 UTC
cvs commit: xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap WSIFSOAPMappingRegistry.java WSIFPort_ApacheSOAP.java
owenb 2002/08/06 02:48:16
Modified: java/src/org/apache/wsif/providers/soap/apachesoap
WSIFPort_ApacheSOAP.java
Added: java/src/org/apache/wsif/providers/soap/apachesoap
WSIFSOAPMappingRegistry.java
Log:
Added support for SOAP-ENC simple types when using the Apache SOAP provider
Revision Changes Path
1.11 +2 -1 xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFPort_ApacheSOAP.java
Index: WSIFPort_ApacheSOAP.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFPort_ApacheSOAP.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- WSIFPort_ApacheSOAP.java 24 Jul 2002 13:28:30 -0000 1.10
+++ WSIFPort_ApacheSOAP.java 6 Aug 2002 09:48:16 -0000 1.11
@@ -305,7 +305,8 @@
Trc.entry(this);
if ( call == null ) {
call = new Call();
- call.setSOAPMappingRegistry( createSOAPMappingRegistry( call ) );
+ call.setSOAPMappingRegistry(
+ new WSIFSOAPMappingRegistry(createSOAPMappingRegistry( call )));
prepareTypeMappings();
}
Trc.exit(call);
1.1 xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apachesoap/WSIFSOAPMappingRegistry.java
Index: WSIFSOAPMappingRegistry.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 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 "WSIF" 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 apache@apache.org.
*
* 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) 2001, 2002, 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.wsif.providers.soap.apachesoap;
import java.math.BigDecimal;
import org.apache.soap.Constants;
import org.apache.soap.encoding.SOAPMappingRegistry;
import org.apache.soap.util.xml.Deserializer;
import org.apache.soap.util.xml.QName;
import org.apache.soap.util.xml.Serializer;
import org.apache.wsif.WSIFConstants;
import org.apache.wsif.logging.Trc;
/**
* An extension of SOAPMappingRegistry which can handle SOAP-ENC simple types
* @author Owen Burroughs <ow...@apache.org>
*/
public class WSIFSOAPMappingRegistry extends SOAPMappingRegistry {
/**
* Constructor for WSIFSOAPMappingRegistry
*/
public WSIFSOAPMappingRegistry() {
super();
Trc.entry(this);
Trc.exit();
}
/**
* Constructor for WSIFSOAPMappingRegistry
* @param registry The parent SOAP mapping registry
*/
public WSIFSOAPMappingRegistry(SOAPMappingRegistry registry) {
super(registry);
Trc.entry(this, registry);
Trc.exit();
}
/**
* Constructor for WSIFSOAPMappingRegistry
* @param registry The parent SOAP mapping registry
* @param schemaURI The namespace URI of XSD to be used for serializers.
*/
public WSIFSOAPMappingRegistry(
SOAPMappingRegistry registry,
String schemaURI) {
super(registry, schemaURI);
Trc.entry(this, registry, schemaURI);
Trc.exit();
}
/**
* Get the serializer for the specified class and encoding
* @param javaType The class to serialize
* @param encodingStyleURI The namespace of the encoding
* @return The serializer if found or null otherwise
*/
protected Serializer querySerializer_(
Class javaType,
String encodingStyleURI) {
Trc.entry(this, javaType, encodingStyleURI);
Serializer ser = super.querySerializer_(javaType, encodingStyleURI);
Trc.exit(ser);
return ser;
}
/**
* Get the deserializer for the specified element and encoding
* @param elementType The element to deserialize
* @param encodingStyleURI The namespace of the encoding
* @return The deserializer if found or null otherwise
*/
protected Deserializer queryDeserializer_(
QName elementType,
String encodingStyleURI) {
Trc.entry(this, elementType, encodingStyleURI);
Deserializer deser = null;
if (elementType != null
&& elementType.getNamespaceURI().equals(
WSIFConstants.NS_URI_SOAP_ENC)) {
QName qn = getEquivalentXSDSimpleType(elementType);
if (qn != null) {
deser = super.queryDeserializer_(qn, encodingStyleURI);
}
}
if (deser == null) {
deser = super.queryDeserializer_(elementType, encodingStyleURI);
}
Trc.exit(deser);
return deser;
}
/**
* Find the element type that is mapped to the given Java class
* @param javaType The Java class
* @param encodingStyleURI The namespace of the encoding
* @return The corresponding element type or null is no mapping found
*/
protected QName queryElementType_(
Class javaType,
String encodingStyleURI) {
return super.queryElementType_(javaType, encodingStyleURI);
}
/**
* Find the Java class that is mapped to the given element type
* @param elementType The element type
* @param encodingStyleURI The namespace of the encoding
* @return The corresponding Java class or null is no mapping found
*/
protected Class queryJavaType_(
QName elementType,
String encodingStyleURI) {
Class cls = null;
if (elementType != null
&& elementType.getNamespaceURI().equals(
WSIFConstants.NS_URI_SOAP_ENC)) {
cls = resolveSOAPENCSimpleType(elementType);
}
if (cls == null) {
return super.queryJavaType_(elementType, encodingStyleURI);
}
return cls;
}
private QName getEquivalentXSDSimpleType(QName elementType) {
if (elementType == null
|| !elementType.getNamespaceURI().equals(
WSIFConstants.NS_URI_SOAP_ENC)) {
return null;
}
String lp = elementType.getLocalPart();
if (lp == null) {
return null;
}
if (lp.equals("string")) {
return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "string");
} else if (lp.equals("boolean")) {
return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "boolean");
} else if (lp.equals("float")) {
return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "float");
} else if (lp.equals("double")) {
return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "double");
} else if (lp.equals("decimal")) {
return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "decimal");
} else if (lp.equals("int")) {
return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "int");
} else if (lp.equals("short")) {
return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "short");
} else if (lp.equals("byte")) {
return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "byte");
} else if (lp.equals("base64")) {
return new QName(WSIFConstants.NS_URI_2001_SCHEMA_XSD, "base64Binary");
} else {
return null;
}
}
private Class resolveSOAPENCSimpleType(QName elementType) {
if (elementType == null
|| !elementType.getNamespaceURI().equals(
WSIFConstants.NS_URI_SOAP_ENC)) {
return null;
}
String lp = elementType.getLocalPart();
if (lp == null) {
return null;
}
if (lp.equals("string")) {
return String.class;
} else if (lp.equals("boolean")) {
return Boolean.class;
} else if (lp.equals("float")) {
return Float.class;
} else if (lp.equals("double")) {
return Double.class;
} else if (lp.equals("decimal")) {
return BigDecimal.class;
} else if (lp.equals("int")) {
return Integer.class;
} else if (lp.equals("short")) {
return Short.class;
} else if (lp.equals("byte")) {
return Byte.class;
} else if (lp.equals("base64")) {
return byte[].class;
} else {
return null;
}
}
}