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 di...@apache.org on 2002/05/07 18:08:52 UTC
cvs commit: xml-axis/java/test/wsdl/extensibility ExtensibilityQuery.wsdl ExtensibilityQueryBindingImpl.java ExtensibilityQueryTestCase.java QueryTypes.wsdl server-deploy.wsdd
dims 02/05/07 09:08:51
Modified: java/src/org/apache/axis/encoding/ser BeanDeserializer.java
BeanSerializer.java ElementDeserializer.java
ElementSerializer.java
java/src/org/apache/axis/message RPCHandler.java
java/src/org/apache/axis/utils resources.properties
java/src/org/apache/axis/wsdl WSDL2Java.java
java/src/org/apache/axis/wsdl/toJava Emitter.java
JavaServiceIfaceWriter.java
JavaServiceImplWriter.java JavaSkelWriter.java
JavaStubWriter.java JavaTestCaseWriter.java
SchemaUtils.java
java/test/wsdl Wsdl2javaTestSuite.xml
Added: java/src/org/apache/axis/encoding
AttributeSerializationContextImpl.java
java/test/wsdl/extensibility ExtensibilityQuery.wsdl
ExtensibilityQueryBindingImpl.java
ExtensibilityQueryTestCase.java QueryTypes.wsdl
server-deploy.wsdd
Log:
Patch for supporting xsd:any namespace="##any" from "Thomas Sandholm" <sa...@mcs.anl.gov>
Revision Changes Path
1.1 xml-axis/java/src/org/apache/axis/encoding/AttributeSerializationContextImpl.java
Index: AttributeSerializationContextImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 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 "Axis" 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. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.axis.encoding;
import org.xml.sax.Attributes;
import javax.xml.rpc.namespace.QName;
import java.io.IOException;
import java.io.Writer;
/** Used to suppress element tag serialization when serializing simple
* types into attributes.
*
* @author Thomas Sandholm (sandholm@mcs.anl.gov)
*/
public class AttributeSerializationContextImpl extends SerializationContextImpl
{
SerializationContext parent;
public AttributeSerializationContextImpl(Writer writer, SerializationContext parent)
{
super(writer);
this.parent = parent;
}
public void startElement(QName qName, Attributes attributes)
throws IOException
{
// suppressed
}
public void endElement()
throws IOException
{
// suppressed
}
public String qName2String(QName qname)
{
return parent.qName2String(qname);
}
}
1.23 +41 -3 xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java
Index: BeanDeserializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- BeanDeserializer.java 1 May 2002 22:06:47 -0000 1.22
+++ BeanDeserializer.java 7 May 2002 16:08:49 -0000 1.23
@@ -55,6 +55,8 @@
package org.apache.axis.encoding.ser;
+import org.apache.axis.MessageContext;
+import org.apache.axis.Constants;
import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.DeserializationContext;
import org.apache.axis.encoding.Deserializer;
@@ -72,6 +74,7 @@
import javax.xml.rpc.namespace.QName;
import java.io.Serializable;
import java.util.HashMap;
+import java.util.Iterator;
/**
* General purpose deserializer for an arbitrary java bean.
@@ -181,7 +184,7 @@
// code attempts to get the meta data from the base class.
// (this fix does not work in all cases, but is necessary to
// get comprehensive tests Animal - Cat inheritance to work).
- if (propDesc == null) {
+ if (propDesc == null) {
Class superClass = javaType;
while (superClass != null && propDesc == null) {
superClass = superClass.getSuperclass();
@@ -204,6 +207,25 @@
}
}
}
+ // try and see if this is an xsd:any namespace="##any" element before reporting a problem
+ QName qn = null;
+ Deserializer dSer = null;
+ MessageContext messageContext = context.getMessageContext();
+ if (propDesc == null && !messageContext.isEncoded()) {
+ // try to put unknown elements into an Object[] property
+ propDesc = getObjectPropertyDesc(elemQName, context);
+ if (propDesc != null) {
+ dSer = context.getDeserializerForType(elemQName);
+ if (dSer == null) {
+ qn = Constants.XSD_ANYTYPE;
+ // make sure that the Element Deserializer deserializes the current element and not the child
+ messageContext.setProperty("DeserializeCurrentElement", Boolean.TRUE);
+ } else {
+ qn = elemQName;
+ }
+ }
+ }
+
if (propDesc == null) {
// No such field
@@ -215,10 +237,14 @@
// Determine the QName for this child element.
// Look at the type attribute specified. If this fails,
// use the javaType of the property to get the type qname.
- QName qn = context.getTypeFromAttributes(namespace, localName, attributes);
+ if (qn == null) {
+ qn = context.getTypeFromAttributes(namespace, localName, attributes);
+ }
// get the deserializer
- Deserializer dSer = context.getDeserializerForType(qn);
+ if (dSer == null) {
+ dSer = context.getDeserializerForType(qn);
+ }
// If no deserializer, use the base DeserializerImpl.
// There may not be enough information yet to choose the
@@ -249,6 +275,17 @@
return (SOAPHandler)dSer;
}
+ public BeanPropertyDescriptor getObjectPropertyDesc(QName qname, DeserializationContext context) {
+ for (Iterator iterator = propertyMap.values().iterator(); iterator.hasNext();) {
+ BeanPropertyDescriptor propertyDesc = (BeanPropertyDescriptor) iterator.next();
+ // try to find xsd:any namespace="##any" property
+ if (propertyDesc.getName().equals("any") && propertyDesc.getType().getName().equals("java.lang.Object")) {
+ return propertyDesc;
+ }
+ }
+ return null;
+ }
+
/**
* Set the bean properties that correspond to element attributes.
*
@@ -320,6 +357,7 @@
// Success! Create an object from the string and set
// it in the bean
try {
+ dSer.onStartElement(namespace, localName, qName, attributes, context);
Object val = ((SimpleDeserializer)dSer).
makeValue(attributes.getValue(i));
bpd.set(value, val);
1.30 +34 -12 xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
Index: BeanSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- BeanSerializer.java 28 Apr 2002 18:10:56 -0000 1.29
+++ BeanSerializer.java 7 May 2002 16:08:49 -0000 1.30
@@ -60,6 +60,7 @@
import org.apache.axis.description.FieldDesc;
import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.SerializationContext;
+import org.apache.axis.encoding.AttributeSerializationContextImpl;
import org.apache.axis.encoding.Serializer;
import org.apache.axis.utils.BeanPropertyDescriptor;
import org.apache.axis.utils.BeanUtils;
@@ -74,6 +75,7 @@
import javax.xml.rpc.namespace.QName;
import java.io.IOException;
import java.io.Serializable;
+import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.util.List;
@@ -125,7 +127,14 @@
// properties are actually attributes, add those to the element
// attribute list
Attributes beanAttrs = getObjectAttributes(value, attributes, context);
- context.startElement(name, beanAttrs);
+
+ // check whether we have and xsd:any namespace="##any" type
+ boolean suppressElement = !context.getMessageContext().isEncoded() &&
+ name.getNamespaceURI().equals("") &&
+ name.getLocalPart().equals("any");
+
+ if (!suppressElement)
+ context.startElement(name, beanAttrs);
try {
// Serialize each property
@@ -133,7 +142,6 @@
String propName = propertyDescriptor[i].getName();
if (propName.equals("class"))
continue;
-
QName qname = null;
// If we have type metadata, check to see what we're doing
@@ -203,7 +211,8 @@
throw new IOException(e.toString());
}
- context.endElement();
+ if (!suppressElement)
+ context.endElement();
}
@@ -407,15 +416,7 @@
// the attribute may be more sophisticated. For example, don't
// serialize if the attribute matches the default value.
if (propValue != null) {
- String propString = propValue.toString();
- String namespace = qname.getNamespaceURI();
- String localName = qname.getLocalPart();
-
- attrs.addAttribute(namespace,
- localName,
- context.qName2String(qname),
- "CDATA",
- propString);
+ setAttributeProperty(propValue, qname, attrs, context);
}
}
}
@@ -426,4 +427,25 @@
return attrs;
}
+
+ private void setAttributeProperty(Object propValue,
+ QName qname,
+ AttributesImpl attrs,
+ SerializationContext context) throws Exception {
+ StringWriter writer = new StringWriter();
+ SerializationContext attributeContext = new AttributeSerializationContextImpl(writer, context);
+ attributeContext.serialize(qname,
+ null,
+ propValue, propValue.getClass());
+ writer.close();
+ String propString = writer.getBuffer().toString();
+ String namespace = qname.getNamespaceURI();
+ String localName = qname.getLocalPart();
+
+ attrs.addAttribute(namespace,
+ localName,
+ context.qName2String(qname),
+ "CDATA",
+ propString);
+ }
}
1.4 +10 -2 xml-axis/java/src/org/apache/axis/encoding/ser/ElementDeserializer.java
Index: ElementDeserializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/ElementDeserializer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElementDeserializer.java 25 Feb 2002 17:38:15 -0000 1.3
+++ ElementDeserializer.java 7 May 2002 16:08:50 -0000 1.4
@@ -64,8 +64,9 @@
import java.util.ArrayList;
-import org.apache.axis.message.MessageElement ;
-import org.apache.axis.message.SOAPHandler ;
+import org.apache.axis.MessageContext;
+import org.apache.axis.message.MessageElement;
+import org.apache.axis.message.SOAPHandler;
import org.apache.axis.encoding.Serializer;
import org.apache.axis.encoding.SerializerFactory;
@@ -98,6 +99,13 @@
try {
MessageElement msgElem = context.getCurElement();
if ( msgElem != null ) {
+ MessageContext messageContext = context.getMessageContext();
+ Boolean currentElement = (Boolean) messageContext.getProperty("DeserializeCurrentElement");
+ if (currentElement != null && currentElement.booleanValue()) {
+ value = msgElem.getAsDOM();
+ messageContext.setProperty("SerializeCurrentElement", Boolean.FALSE);
+ return;
+ }
ArrayList children = msgElem.getChildren();
if ( children != null ) {
msgElem = (MessageElement) children.get(0);
1.3 +9 -2 xml-axis/java/src/org/apache/axis/encoding/ser/ElementSerializer.java
Index: ElementSerializer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/ElementSerializer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ElementSerializer.java 2 Feb 2002 18:06:18 -0000 1.2
+++ ElementSerializer.java 7 May 2002 16:08:50 -0000 1.3
@@ -93,9 +93,16 @@
if (!(value instanceof Element))
throw new IOException(JavaUtils.getMessage("cantSerialize01"));
- context.startElement(name, attributes);
+ // suppress xsd:any namespace="##any" elements
+ boolean suppressElement = (!context.getMessageContext().isEncoded() &&
+ name.getNamespaceURI().equals("") &&
+ name.getLocalPart().equals("any"));
+
+ if (!suppressElement)
+ context.startElement(name, attributes);
context.writeDOMElement((Element)value);
- context.endElement();
+ if (!suppressElement)
+ context.endElement();
}
public String getMechanismType() { return Constants.AXIS_SAX; }
1.36 +5 -2 xml-axis/java/src/org/apache/axis/message/RPCHandler.java
Index: RPCHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCHandler.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- RPCHandler.java 23 Apr 2002 03:54:26 -0000 1.35
+++ RPCHandler.java 7 May 2002 16:08:50 -0000 1.36
@@ -216,8 +216,11 @@
if ( isNil != null && isNil.equals("true") )
return( (SOAPHandler) new DeserializerImpl() );
- Deserializer dser;
- if (type != null) {
+ Deserializer dser = null;
+ if ((type == null) && (namespace != null) && (!namespace.equals(""))) {
+ dser = context.getDeserializerForType(qname);
+ }
+ if ((type != null) && (dser == null)) {
dser = context.getDeserializerForType(type);
} else {
dser = new DeserializerImpl();
1.96 +2 -0 xml-axis/java/src/org/apache/axis/utils/resources.properties
Index: resources.properties
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.properties,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- resources.properties 6 May 2002 19:41:47 -0000 1.95
+++ resources.properties 7 May 2002 16:08:50 -0000 1.96
@@ -451,6 +451,8 @@
optionTest00=emit junit testcase class for web service
optionVerbose00=print informational messages
+
+
outMsg00=Out message: {0}
params00=Parameters are: {0}
parent00=parent
1.25 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java
Index: WSDL2Java.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- WSDL2Java.java 15 Apr 2002 02:35:58 -0000 1.24
+++ WSDL2Java.java 7 May 2002 16:08:50 -0000 1.25
@@ -441,6 +441,7 @@
public void setPassword(String password) {
this.password = password;
}
+
//
// Command line switches
//
@@ -672,7 +673,6 @@
case PASSWORD_OPT:
wsdl2java.setPassword(option.getArgument());
break;
-
}
}
1.33 +1 -0 xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java
Index: Emitter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- Emitter.java 16 Apr 2002 20:26:32 -0000 1.32
+++ Emitter.java 7 May 2002 16:08:50 -0000 1.33
@@ -115,6 +115,7 @@
protected String NStoPkgFilename = "NStoPkg.properties";
protected File NStoPkgFile = null;
+
/**
* Default constructor.
*/
1.2 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceIfaceWriter.java
Index: JavaServiceIfaceWriter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceIfaceWriter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JavaServiceIfaceWriter.java 5 Feb 2002 16:22:40 -0000 1.1
+++ JavaServiceIfaceWriter.java 7 May 2002 16:08:50 -0000 1.2
@@ -142,7 +142,7 @@
// If there is not literal use, the interface name is the portType name.
// Otherwise it is the binding name.
- String bindingType = bEntry.hasLiteral() ?
+ String bindingType = (bEntry.hasLiteral()) ?
bEntry.getName() : ptEntry.getName();
// Write out the get<PortName> methods
1.9 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java
Index: JavaServiceImplWriter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- JavaServiceImplWriter.java 21 Mar 2002 14:28:53 -0000 1.8
+++ JavaServiceImplWriter.java 7 May 2002 16:08:50 -0000 1.9
@@ -152,7 +152,7 @@
// If there is not literal use, the interface name is the portType name.
// Otherwise it is the binding name.
- String bindingType = bEntry.hasLiteral() ?
+ String bindingType = (bEntry.hasLiteral()) ?
bEntry.getName() : ptEntry.getName();
// getPort(Class) must return a stub for an interface. Collect all
1.22 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java
Index: JavaSkelWriter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- JavaSkelWriter.java 15 Apr 2002 02:35:58 -0000 1.21
+++ JavaSkelWriter.java 7 May 2002 16:08:50 -0000 1.22
@@ -107,7 +107,7 @@
// If there is not literal use, the interface name is the portType name.
// Otherwise it is the binding name.
- String portTypeName = bEntry.hasLiteral() ?
+ String portTypeName = (bEntry.hasLiteral()) ?
bEntry.getName () : ptEntry.getName();
boolean isRPC = true;
if (bEntry.getBindingStyle() == BindingEntry.STYLE_DOCUMENT) {
1.56 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
Index: JavaStubWriter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- JavaStubWriter.java 16 Apr 2002 20:26:32 -0000 1.55
+++ JavaStubWriter.java 7 May 2002 16:08:50 -0000 1.56
@@ -110,7 +110,7 @@
// If there is not literal use, the interface name is the portType name.
// Otherwise it is the binding name.
- String portTypeName = bEntry.hasLiteral() ?
+ String portTypeName = (bEntry.hasLiteral()) ?
bEntry.getName() : ptEntry.getName();
boolean isRPC = true;
if (bEntry.getBindingStyle() == BindingEntry.STYLE_DOCUMENT) {
1.23 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java
Index: JavaTestCaseWriter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- JavaTestCaseWriter.java 1 May 2002 17:17:15 -0000 1.22
+++ JavaTestCaseWriter.java 7 May 2002 16:08:50 -0000 1.23
@@ -174,7 +174,7 @@
// If there is not literal use, the interface name is the portType name.
// Otherwise it is the binding name.
- String bindingType = bEntry.hasLiteral() ?
+ String bindingType = (bEntry.hasLiteral()) ?
bEntry.getName() : ptEntry.getName();
writeBindingAssignment(bindingType, portName);
1.21 +5 -0 xml-axis/java/src/org/apache/axis/wsdl/toJava/SchemaUtils.java
Index: SchemaUtils.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/SchemaUtils.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- SchemaUtils.java 4 Apr 2002 19:17:12 -0000 1.20
+++ SchemaUtils.java 7 May 2002 16:08:51 -0000 1.21
@@ -265,6 +265,11 @@
v.addAll(processSequenceNode(children.item(j), symbolTable));
} else if (subNodeKind.getLocalPart().equals("group")) {
v.addAll(processGroupNode(children.item(j), symbolTable));
+ } else if (subNodeKind.getLocalPart().equals("any")) {
+ TypeEntry type = new DefinedType(Utils.getWSDLQName(Constants.XSD_ANYTYPE), sequenceNode);
+ type.setName("java.lang.Object");
+ ElementDecl elem = new ElementDecl(type, Utils.getAxisQName(new QName("","any")));
+ v.add(elem);
} else if (subNodeKind.getLocalPart().equals("element")) {
ElementDecl elem =
processChildElementNode(children.item(j),
1.96 +18 -0 xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml
Index: Wsdl2javaTestSuite.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- Wsdl2javaTestSuite.xml 18 Apr 2002 13:50:42 -0000 1.95
+++ Wsdl2javaTestSuite.xml 7 May 2002 16:08:51 -0000 1.96
@@ -325,6 +325,24 @@
<mapping namespace="urn:CityBBB" package="test.wsdl.wrapped"/>
</wsdl2java>
+ <!-- Extensibility Sample Test -->
+ <wsdl2java url="test/wsdl/extensibility/QueryTypes.wsdl"
+ output="build/work"
+ deployscope="session"
+ serverSide="no"
+ skeletonDeploy="no"
+ testcase="no">
+ <mapping namespace="urn:QueryTypes" package="test.wsdl.extensibility"/>
+ </wsdl2java>
+ <wsdl2java url="test/wsdl/extensibility/ExtensibilityQuery.wsdl"
+ output="build/work"
+ deployscope="session"
+ serverSide="yes"
+ skeletonDeploy="yes"
+ testcase="yes">
+ <mapping namespace="urn:ExtensibilityQuery" package="test.wsdl.extensibility"/>
+ </wsdl2java>
+
<!-- Import Test 1: some namespace->package mappings from the -->
<!-- command line, some generated, some from -->
<!-- NStoPkg.properties. -->
1.1 xml-axis/java/test/wsdl/extensibility/ExtensibilityQuery.wsdl
Index: ExtensibilityQuery.wsdl
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="ExtensibilityQuery" targetNamespace="urn:ExtensibilityQuery"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="urn:ExtensibilityQuery" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<types>
<xsd:schema attributeFormDefault="qualified"
elementFormDefault="qualified" targetNamespace="urn:ExtensibilityQuery">
<xsd:complexType name="ExtensibilityType">
<xsd:sequence>
<xsd:any namespace="##any"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="query">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="queryExpression" type="tns:ExtensibilityType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="queryResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="queryResult" type="tns:ExtensibilityType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="queryIn">
<part element="tns:query" name="parameters" />
</message>
<message name="queryOut">
<part element="tns:queryResponse" name="parameters" />
</message>
<portType name="ExtensibilityQueryPortType">
<operation name="query">
<input message="tns:queryIn" />
<output message="tns:queryOut" />
</operation>
</portType>
<binding name="ExtensibilityQueryBinding" type="tns:ExtensibilityQueryPortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="query">
<soap:operation soapAction="query" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="ExtensibilityQuery">
<port binding="tns:ExtensibilityQueryBinding" name="ExtensibilityQueryPort">
<soap:address location="http://localhost:8080/axis/services/ExtensibilityQueryPort"/>
</port>
</service>
</definitions>
1.1 xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryBindingImpl.java
Index: ExtensibilityQueryBindingImpl.java
===================================================================
/**
* ExtensibilityQueryBindingImpl.java
*
*/
package test.wsdl.extensibility;
import java.util.Calendar;
import javax.xml.rpc.namespace.QName;
public class ExtensibilityQueryBindingImpl implements ExtensibilityQueryBinding {
public ExtensibilityType query(ExtensibilityType query) throws java.rmi.RemoteException {
ExtensibilityType result = new ExtensibilityType();
Object obj = query.getAny();
if (obj instanceof BookQuery) {
System.out.println("ExtensibilityQueryBindingImpl: Found book");
BookQuery bookQuery = (BookQuery) obj;
String subject = bookQuery.getSubject();
QueryResultType queryResultType = new QueryResultType();
QueryResult queryResult = new QueryResult();
queryResult.setName(subject);
queryResult.setValue("The Grid");
queryResult.setTime(Calendar.getInstance());
queryResult.setQueryType(new QName("urn:QueryType","BookQuery"));
queryResultType.setQueryResult(queryResult);
result.setAny(queryResultType);
}
return result;
}
}
1.1 xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryTestCase.java
Index: ExtensibilityQueryTestCase.java
===================================================================
/**
* ExtensibilityQueryTestCase.java
*
* This file was auto-generated from WSDL
* by the Apache Axis Wsdl2java emitter.
*/
package test.wsdl.extensibility;
import org.apache.axis.EngineConfiguration;
import org.apache.axis.AxisEngine;
import org.apache.axis.client.AdminClient;
import org.apache.axis.encoding.TypeMappingRegistry;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import javax.xml.rpc.encoding.TypeMapping;
import javax.xml.rpc.namespace.QName;
import java.util.Calendar;
public class ExtensibilityQueryTestCase extends junit.framework.TestCase {
public ExtensibilityQueryTestCase(String name) {
super(name);
}
public void testQuery() {
ExtensibilityQueryBinding binding;
try {
ExtensibilityQueryLocator locator = new ExtensibilityQueryLocator();
binding = locator.getExtensibilityQueryPort();
addDynamicTypeMappings(locator.getEngine());
deployServer();
}
catch (javax.xml.rpc.ServiceException jre) {
throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
}
catch (Exception e) {
throw new junit.framework.AssertionFailedError("Binding initialization Exception caught: " + e);
}
assertTrue("binding is null", binding != null);
try {
ExtensibilityType expression = new ExtensibilityType();
FindBooksQueryExpressionType bookQuery = new FindBooksQueryExpressionType();
BookQuery book = new BookQuery();
book.setSubject("Computer Science");
bookQuery.setBookQuery(book);
expression.setAny(bookQuery);
ExtensibilityType any = binding.query(expression);
QueryResult result = (QueryResult) any.getAny();
System.out.println("ExtensibilityQueryTestCase: Result name: " + result.getName() + " value: " + result.getValue() +
" date: " + result.getTime().getTime() + " type: " + result.getQueryType());
assertTrue(result.getName().equals("Computer Science"));
assertTrue(result.getValue().equals("The Grid"));
assertTrue(result.getTime().before(Calendar.getInstance()));
assertTrue(result.getQueryType().getNamespaceURI().equals("urn:QueryType"));
assertTrue(result.getQueryType().getLocalPart().equals("BookQuery"));
}
catch (java.rmi.RemoteException re) {
throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re);
}
}
private void addDynamicTypeMappings(AxisEngine engine) throws Exception {
TypeMappingRegistry registry = engine.getTypeMappingRegistry();
TypeMapping mapping = registry.createTypeMapping();
QName queryQname = new QName("urn:QueryTypes", "FindBooksQueryExpressionType");
mapping.register(FindBooksQueryExpressionType.class,
queryQname,
new BeanSerializerFactory(FindBooksQueryExpressionType.class, queryQname),
new BeanDeserializerFactory(FindBooksQueryExpressionType.class, queryQname));
QName bookQname = new QName("urn:QueryTypes", "BookQuery");
mapping.register(BookQuery.class,
bookQname,
new BeanSerializerFactory(BookQuery.class, bookQname),
new BeanDeserializerFactory(BookQuery.class, bookQname));
QName resultQname = new QName("urn:QueryTypes", "queryResult");
mapping.register(QueryResult.class,
resultQname,
new BeanSerializerFactory(QueryResult.class, resultQname),
new BeanDeserializerFactory(QueryResult.class, resultQname));
registry.register("",mapping);
EngineConfiguration config = engine.getConfig();
config.writeEngineConfig(engine);
}
private void deployServer() {
AdminClient.main(new String[] { "test/wsdl/extensibility/server-deploy.wsdd" });
}
}
1.1 xml-axis/java/test/wsdl/extensibility/QueryTypes.wsdl
Index: QueryTypes.wsdl
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="QueryTypes" targetNamespace="urn:QueryTypes"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="urn:QueryTypes" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<types>
<xsd:schema attributeFormDefault="qualified"
elementFormDefault="qualified" targetNamespace="urn:QueryTypes">
<xsd:element name="FindBooksQueryExpressionType">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="bookQuery">
<xsd:complexType>
<xsd:attribute name="subject" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="QueryResultType">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="queryResult">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="value" type="xsd:string"/>
<xsd:attribute name="time" type="xsd:dateTime"/>
<xsd:attribute name="queryType" type="xsd:QName"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
</definitions>
1.1 xml-axis/java/test/wsdl/extensibility/server-deploy.wsdd
Index: server-deploy.wsdd
===================================================================
<!-- Use this file to deploy some handlers/chains and services -->
<!-- Two ways to do this: -->
<!-- java org.apache.axis.client.AdminClient deploy.wsdd -->
<!-- after the axis server is running -->
<!-- or -->
<!-- java org.apache.axis.utils.Admin client|server deploy.wsdd -->
<!-- from the same directory that the Axis engine runs -->
<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:query="urn:QueryTypes"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="ExtensibilityQueryPort" provider="java:RPC" style="wrapped">
<parameter name="className" value="test.wsdl.extensibility.ExtensibilityQueryBindingSkeleton"/>
<parameter name="allowedMethods" value="*"/>
<parameter name="scope" value="Session"/>
<typeMapping
xmlns:ns="urn:ExtensibilityQuery"
qname="ns:ExtensibilityType"
type="java:test.wsdl.extensibility.ExtensibilityType"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
qname="xsd:anyType"
type="java:java.lang.Object"
serializer="org.apache.axis.encoding.ser.ElementSerializerFactory"
deserializer="org.apache.axis.encoding.ser.ElementDeserializerFactory"
encodingStyle=""
/>
<typeMapping
qname="query:bookQuery"
type="java:test.wsdl.extensibility.BookQuery"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
qname="query:QueryResultType"
type="java:test.wsdl.extensibility.QueryResultType"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
qname="query:QueryResult"
type="java:test.wsdl.extensibility.QueryResult"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
</service>
</deployment>