DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18242>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18242 Document Literal WSDL Processing - maxOccurs="unbounded" Summary: Document Literal WSDL Processing - maxOccurs="unbounded" Product: Axis Version: current (nightly) Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: WSDL processing AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Axis creates methods like: public void setNameofComplexType(int i, samples.pubsub.Message value) { this.message[i] = value; } for elements that reference complexTypes and set maxOccurs"unbounded". If this method is used, at runtime, a NullPointer is generated because internally, the array (this.message[]) is not dimensioned. I am attaching a WSDL, an example of one of the classes in question and a basic impl of the web service that attempts to use this method. ## WSDL ## <?xml version="1.0" encoding="UTF-8"?> <definitions name="PubSubService" targetNamespace="http://soapinterop.org/WSDLInteropTestDocLit" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:SOAP- ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soapinterop.org/WSDLInteropTestDocLit" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://soapinterop.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <types> <schema targetNamespace="http://soapinterop.org/xsd" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" elementFormDefault="qualified"> <complexType name="Message"> <sequence> <element name="Id" type="xsd:int"/> <element name="Text" type="xsd:string"/> </sequence> </complexType> <complexType name="MessageAttribute"> <sequence> <element name="Key" type="xsd:string"/> <element name="Value" type="xsd:string"/> </sequence> </complexType> <complexType name="PubSubStructure"> <sequence> <element name="TopicName" type="xsd:string"/> <element name="MessageAttribute" type="xsd1:MessageAttribute" maxOccurs="unbounded"/> <element name="Payload" type="xsd:string"/> </sequence> </complexType> <complexType name="CmdResponse"> <sequence> <element name="CmdStatus" type="xsd:int"/> <element name="Message" type="xsd1:Message" maxOccurs="unbounded"/> </sequence> </complexType> <!-- mjh start --> <element name="PubSubStructure" type="xsd1:PubSubStructure"/> <element name="CmdResponse" type="xsd1:CmdResponse"/> <!-- mjh stop --> </schema> </types> <!-- mjh start --> <message name="pubSub"> <part element="xsd1:PubSubStructure" name="a"/> </message> <message name="pubSubResponse"> <part element="xsd1:CmdResponse" name="result"/> </message> <!-- mjh stop --> <portType name="PubSubServicePortType"> <!-- mjh start --> <operation name="publishEvent"> <input message="tns:pubSub" name="pubSub"/> <output message="tns:pubSubResponse" name="pubSubResponse"/> </operation> <!-- mjh stop --> </portType> <binding name="PubSubServicePortBinding" type="tns:PubSubServicePortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <!-- mjh start --> <operation name="publishEvent"> <soap:operation soapAction="http://soapinterop.org/" style="document"/> <input name="pubSub"> <soap:body namespace="http://soapinterop.org/WSDLInteropTestDocLit" use="literal"/> </input> <output name="pubSubResponse"> <soap:body namespace="http://soapinterop.org/WSDLInteropTestDocLit" use="literal"/> </output> </operation> <!-- mjh stop --> </binding> <service name="PubSubService"> <port binding="tns:PubSubServicePortBinding" name="PubSubService"> <soap:address location="http://mssoapinterop.org/stkv3/wsdl/interopTestDocLit.wsdl"/> </port> </service> </definitions> ## Axis Generated Class ## /** * CmdResponse.java * * This file was auto-generated from WSDL * by the Apache Axis WSDL2Java emitter. */ package samples.pubsub; public class CmdResponse implements java.io.Serializable { private java.lang.String cmdStatus; private samples.pubsub.Message[] message; // ##### < -- The problem public CmdResponse() { } public java.lang.String getCmdStatus() { return cmdStatus; } public void setCmdStatus(java.lang.String cmdStatus) { this.cmdStatus = cmdStatus; } public samples.pubsub.Message[] getMessage() { return message; } public void setMessage(samples.pubsub.Message[] message) { this.message = message; } public samples.pubsub.Message getMessage(int i) { return message[i]; } public void setMessage(int i, samples.pubsub.Message value) { this.message[i] = value; } private java.lang.Object __equalsCalc = null; public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof CmdResponse)) return false; CmdResponse other = (CmdResponse) obj; if (obj == null) return false; if (this == obj) return true; if (__equalsCalc != null) { return (__equalsCalc == obj); } __equalsCalc = obj; boolean _equals; _equals = true && ((this.cmdStatus==null && other.getCmdStatus()==null) || (this.cmdStatus!=null && this.cmdStatus.equals(other.getCmdStatus()))) && ((this.message==null && other.getMessage()==null) || (this.message!=null && java.util.Arrays.equals(this.message, other.getMessage()))); __equalsCalc = null; return _equals; } private boolean __hashCodeCalc = false; public synchronized int hashCode() { if (__hashCodeCalc) { return 0; } __hashCodeCalc = true; int _hashCode = 1; if (getCmdStatus() != null) { _hashCode += getCmdStatus().hashCode(); } if (getMessage() != null) { for (int i=0; i<java.lang.reflect.Array.getLength(getMessage()); i++) { java.lang.Object obj = java.lang.reflect.Array.get(getMessage (), i); if (obj != null && !obj.getClass().isArray()) { _hashCode += obj.hashCode(); } } } __hashCodeCalc = false; return _hashCode; } // Type metadata private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc(CmdResponse.class); static { typeDesc.setXmlType(new javax.xml.namespace.QName ("http://soapinterop.org/xsd", "CmdResponse")); org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("cmdStatus"); elemField.setXmlName(new javax.xml.namespace.QName ("http://soapinterop.org/xsd", "CmdStatus")); elemField.setXmlType(new javax.xml.namespace.QName ("http://www.w3.org/2001/XMLSchema", "string")); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("message"); elemField.setXmlName(new javax.xml.namespace.QName ("http://soapinterop.org/xsd", "Message")); elemField.setXmlType(new javax.xml.namespace.QName ("http://soapinterop.org/xsd", "Message")); typeDesc.addFieldDesc(elemField); } /** * Return type metadata object */ public static org.apache.axis.description.TypeDesc getTypeDesc() { return typeDesc; } /** * Get Custom Serializer */ public static org.apache.axis.encoding.Serializer getSerializer( java.lang.String mechType, java.lang.Class _javaType, javax.xml.namespace.QName _xmlType) { return new org.apache.axis.encoding.ser.BeanSerializer( _javaType, _xmlType, typeDesc); } /** * Get Custom Deserializer */ public static org.apache.axis.encoding.Deserializer getDeserializer( java.lang.String mechType, java.lang.Class _javaType, javax.xml.namespace.QName _xmlType) { return new org.apache.axis.encoding.ser.BeanDeserializer( _javaType, _xmlType, typeDesc); } } ## Basic Web Service Impl ## /** * PubSubServicePortBindingImpl.java * * This file was auto-generated from WSDL * by the Apache Axis WSDL2Java emitter. */ package samples.pubsub; public class PubSubServicePortBindingImpl implements samples.pubsub.PubSubServicePortType{ public samples.pubsub.CmdResponse publishEvent (samples.pubsub.PubSubStructure a) throws java.rmi.RemoteException { System.out.println("the PubSubStructure"+a); CmdResponse resp = new CmdResponse(); resp.setCmdStatus("2"); Message msg1 = new Message(); msg1.setId(1001); msg1.setText("You did not specify the topic name"); resp.setMessage(0, msg1); // ##### < --- Where it chokes Message msg2 = new Message(); msg2.setId(2002); msg2.setText("You did not specify any XML"); resp.setMessage(1, msg2); return resp; } }
