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 "Fadila Mumbasic (JIRA)" <ji...@apache.org> on 2011/05/10 14:38:47 UTC

[jira] [Commented] (AXIS2-5029) Problem with automatically generated WSDL and nested classes

    [ https://issues.apache.org/jira/browse/AXIS2-5029?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13031148#comment-13031148 ] 

Fadila Mumbasic commented on AXIS2-5029:
----------------------------------------

I've found the reason for the missing complex type:

DefaultSchemaGenerator.java adds a complexTypeSchema for the nested class into the typeTables with the name 'package.outerClass_InnerClass'
(line 534; the name is generated using the method getClassName(); )

Later (line 732) the complexType is searched with the name 'package.outerClass$InnerClass' and could not be found, so typeTable.getComplexSchemaType(propertyName) returns null.

I fixed my version in the file TypeTable.java, method

    public QName getComplexSchemaType(String name) {                  
        return (QName) complexTypeMap.get(name);
    }

My patch looks like:
    public QName getComplexSchemaType(String name) {
              
        if ((QName) complexTypeMap.get(name) == null) {
            if (name.indexOf("$") > 0) {
                name = name.replace('$', '_');
            }
        }
        return (QName) complexTypeMap.get(name);
    }

It works for me.

>  Problem with automatically generated WSDL and nested classes
> -------------------------------------------------------------
>
>                 Key: AXIS2-5029
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5029
>             Project: Axis2
>          Issue Type: Bug
>          Components: wsdl
>    Affects Versions: 1.5.3
>         Environment: Windows
>            Reporter: Fadila Mumbasic
>
> The automatically generated WSDL does not contain the "type" attribute
> for the element which corrsponds to the nested class.
> My Java class looks like:
> package com.uniserv.nested.test;
> public class NestedClass {
> 		
> 		public static class InnerStruct{
> 		    private String x;
> 		    private String y;
> 		    
> 		    public InnerStruct(){
> 		        x= "";
> 		        y= "";
> 		    }
> 		    
> 		    public String getX(){
> 		        return this.x;
> 		    }
> 		    
> 		    public String getY(){
>                    return this.y;
>                 }
> 		    
> 		    public void setX(String x){
> 		        this.x = x;
> 		    }
> 		    
> 		    public void setY(String y){
>                    this.y = y;
>                 }
> 		}
> 		
> 		public class Output{
> 		    private InnerStruct[] innerStructArray;
> 		    
> 		    public Output() {
> 		        innerStructArray = null;
> 		    }
> 		    
> 		    public InnerStruct[] getInnerStructArray(){
> 		        return this.innerStructArray;
> 		    }
> 		    
> 		    public void setInnerStructArray (InnerStruct[]
> innerStructArray){
> 		        this.innerStructArray = innerStructArray;
> 		    }		    
> 		}
> 		
> 	    public Output testIt (String a ){
> 	    
> 	        Output  output = new Output();
> 	        InnerStruct[] innerStructArray =
> output.getInnerStructArray();
> 	        
> 	        if(innerStructArray == null){
> 	           
> 	            innerStructArray = new NestedClass.InnerStruct[2];
> 	            
> 	            InnerStruct struct1 = new NestedClass.InnerStruct();
> 	            struct1.setX("x1");
> 	            struct1.setY("y1");
> 	            innerStructArray[0]= struct1;
> 	            
> 	            InnerStruct struct2 = new NestedClass.InnerStruct();
>                   struct2.setX("x2");
>                   struct2.setY("y2");           
>                   innerStructArray[1]= struct2;
> 	        }
> 	    
> 	        output.setInnerStructArray(innerStructArray);
> 	        return output;
> 	    }
> }
> The automaticaly generated WSDL contains following:
> - <wsdl:types>
> - <xs:schema xmlns:ax210="http://test.nested.uniserv.com/xsd"
> attributeFormDefault="qualified" elementFormDefault="qualified"
> targetNamespace="http://test.nested.uniserv.com">
>  	 <xs:import namespace="http://test.nested.uniserv.com/xsd" /> 
> - <xs:element name="testIt">
> - <xs:complexType>
> 	- <xs:sequence>
>  	 <xs:element minOccurs="0" name="a" nillable="true"
> type="xs:string" /> 
>  	 </xs:sequence>
>   </xs:complexType>
>   </xs:element>
> - <xs:element name="testItResponse">
> - <xs:complexType>
> - <xs:sequence>
>   <xs:element minOccurs="0" name="return" nillable="true"
> type="ax210:Output" /> 
>   </xs:sequence>
>   </xs:complexType>
>   </xs:element>
>   </xs:schema>
> - <xs:schema attributeFormDefault="qualified"
> elementFormDefault="qualified"
> targetNamespace="http://test.nested.uniserv.com/xsd">
> - <xs:complexType name="Output">
> - <xs:sequence>
>   <xs:element maxOccurs="unbounded" minOccurs="0"
> name="innerStructArray" nillable="true" /> 
>   </xs:sequence>
>   </xs:complexType>
> - <xs:complexType name="InnerStruct">
> - <xs:sequence>
>   <xs:element minOccurs="0" name="x" nillable="true" type="xs:string" />
>   <xs:element minOccurs="0" name="y" nillable="true" type="xs:string" />
>   </xs:sequence>
>   </xs:complexType>
>   </xs:schema>
>   </wsdl:types>
> The definition of the complexType Output does not contain the type of
> the particular elements:
>  <xs:element maxOccurs="unbounded" minOccurs="0" name="innerStructArray"
> nillable="true" /> 
> I would expect to see
> <xs:element maxOccurs="unbounded" minOccurs="0" name="innerStructArray"
> nillable="true" type="ax210:InnerStruct" /> 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org