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 2005/06/30 22:09:17 UTC
cvs commit: ws-axis/java/src/org/apache/axis/message RPCParam.java
dims 2005/06/30 13:09:17
Modified: java/test/wsdl/wrapped CityBBB.wsdl
java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java
java/src/org/apache/axis/wsdl/symbolTable Parameter.java
SymbolTable.java
java/src/org/apache/axis/description ParameterDesc.java
java/src/org/apache/axis/message RPCParam.java
Log:
Fix for AXIS-2054 - Axis sends xsi:nil for non-nillable, minOccurs=0 parameters
from Dave Marquard
Revision Changes Path
1.4 +2 -2 ws-axis/java/test/wsdl/wrapped/CityBBB.wsdl
Index: CityBBB.wsdl
===================================================================
RCS file: /home/cvs/ws-axis/java/test/wsdl/wrapped/CityBBB.wsdl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CityBBB.wsdl 5 Sep 2002 01:08:38 -0000 1.3
+++ CityBBB.wsdl 30 Jun 2005 20:09:17 -0000 1.4
@@ -20,7 +20,7 @@
<xsd:element name="getAttractions">
<xsd:complexType>
<xsd:sequence>
- <xsd:element maxOccurs="unbounded" minOccurs="0" name="attname"
+ <xsd:element maxOccurs="unbounded" minOccurs="0" nillable="true" name="attname"
type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
@@ -46,7 +46,7 @@
<xsd:element name="getAttractionsResponse">
<xsd:complexType>
<xsd:sequence>
- <xsd:element maxOccurs="unbounded" minOccurs="0" name="_return"
+ <xsd:element maxOccurs="unbounded" minOccurs="0" nillable="true" name="_return"
type="tns:Attraction" />
</xsd:sequence>
</xsd:complexType>
1.153 +6 -0 ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
Index: JavaStubWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -r1.152 -r1.153
--- JavaStubWriter.java 26 Jun 2005 11:17:24 -0000 1.152
+++ JavaStubWriter.java 30 Jun 2005 20:09:17 -0000 1.153
@@ -644,6 +644,12 @@
Utils.getNewQName(itemQName) + ");");
}
+ if (p.isOmittable())
+ pw.println(" param.setOmittable(true);");
+
+ if (p.isNillable())
+ pw.println(" param.setNillable(true);");
+
pw.println(" oper.addParameter(param);");
}
1.12 +19 -0 ws-axis/java/src/org/apache/axis/wsdl/symbolTable/Parameter.java
Index: Parameter.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/symbolTable/Parameter.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Parameter.java 21 Jun 2004 21:30:25 -0000 1.11
+++ Parameter.java 30 Jun 2005 20:09:17 -0000 1.12
@@ -67,6 +67,9 @@
/** Is this an omittable param? */
private boolean omittable = false;
+ /** Is this a nilliable param? */
+ private boolean nillable = false;
+
/**
* Method toString
*
@@ -238,4 +241,20 @@
public void setOmittable(boolean omittable) {
this.omittable = omittable;
}
+
+ /**
+ * Indicates whether this parameter is nillable or not.
+ * @return whether this parameter is nilliable
+ */
+ public boolean isNillable() {
+ return nillable;
+ }
+
+ /**
+ * Indicate whether this parameter is nillable or not.
+ * @param nillable whether this parameter is nilliable
+ */
+ public void setNillable(boolean nillable) {
+ this.nillable = nillable;
+ }
} // class Parameter
1.123 +1 -0 ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java
Index: SymbolTable.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -r1.122 -r1.123
--- SymbolTable.java 13 Jun 2005 02:19:52 -0000 1.122
+++ SymbolTable.java 30 Jun 2005 20:09:17 -0000 1.123
@@ -2224,6 +2224,7 @@
p.setName(paramName);
p.setType(elem.getType());
p.setOmittable(elem.getMinOccursIs0());
+ p.setNillable(elem.getNillable());
fillParamInfo(p, bindingEntry, opName, partName);
v.add(p);
}
1.34 +40 -0 ws-axis/java/src/org/apache/axis/description/ParameterDesc.java
Index: ParameterDesc.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/description/ParameterDesc.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- ParameterDesc.java 4 May 2005 09:45:27 -0000 1.33
+++ ParameterDesc.java 30 Jun 2005 20:09:17 -0000 1.34
@@ -68,6 +68,12 @@
/** The documentation for the parameter */
private String documentation = null;
+ /** Indicates whether this parameter may be omitted or not (i.e., it has minOccurs="0") */
+ private boolean omittable = false;
+
+ /** Indicates whether this parameter is nillable */
+ private boolean nillable = false;
+
public ParameterDesc() {
}
@@ -351,4 +357,38 @@
public void setItemType(QName itemType) {
this.itemType = itemType;
}
+
+ /**
+ * Indicates if this parameter is omittable or not (i.e., if it
+ * has a minimum occurrence of 0).
+ * @return true iff the parameter may be omitted in the request
+ */
+ public boolean isOmittable() {
+ return omittable;
+ }
+
+ /**
+ * Indicate if this parameter is omittable or not (i.e., if it
+ * has a minimum occurrence of 0).
+ * @param omittable whether the parameter may be omitted or not
+ */
+ public void setOmittable(boolean omittable) {
+ this.omittable = omittable;
+ }
+
+ /**
+ * Indicates whether this parameter is nillable or not.
+ * @return whether this parameter is nillable
+ */
+ public boolean isNillable() {
+ return nillable;
+ }
+
+ /**
+ * Indicate if this parameter is nillable.
+ * @param nillable true iff this parameter is nillable
+ */
+ public void setNillable(boolean nillable) {
+ this.nillable = nillable;
+ }
}
1.66 +10 -2 ws-axis/java/src/org/apache/axis/message/RPCParam.java
Index: RPCParam.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/RPCParam.java,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- RPCParam.java 4 May 2005 09:45:27 -0000 1.65
+++ RPCParam.java 30 Jun 2005 20:09:17 -0000 1.66
@@ -168,6 +168,9 @@
// serialize method to search for a compatible xmlType)
Class javaType = value == null ? null: value.getClass();
QName xmlType = null;
+ // we'll send a null unless our description tells us
+ // that we may be omitted
+ Boolean sendNull = Boolean.TRUE;
if (paramDesc != null) {
if (javaType == null) {
javaType = paramDesc.getJavaType() != null ?
@@ -177,7 +180,7 @@
if(clazz == null || !clazz.equals(paramDesc.getJavaType())) {
if (!(javaType.equals(
JavaUtils.getHolderValueType(paramDesc.getJavaType())))) {
-
+
// This must (assumedly) be a polymorphic type - in ALL
// such cases, we must send an xsi:type attribute.
wantXSIType = Boolean.TRUE;
@@ -196,12 +199,17 @@
QName itemType = paramDesc.getItemType();
context.setItemType(itemType);
+
+ // don't send anything if we're able to be omitted,
+ // although we'll prefer to send xsi:nill if possible
+ if (paramDesc.isOmittable() && !paramDesc.isNillable())
+ sendNull = Boolean.FALSE;
}
context.serialize(getQName(), // element qname
null, // no extra attrs
value, // value
xmlType, // java/xml type
- Boolean.TRUE, wantXSIType);
+ sendNull, wantXSIType);
}
private void writeObject(ObjectOutputStream out)