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 "Ragulan (JIRA)" <ax...@ws.apache.org> on 2010/02/15 09:45:27 UTC

[jira] Issue Comment Edited: (AXIS-2250) AXIS array serialization: Incorrect element names of items in a list

    [ https://issues.apache.org/jira/browse/AXIS-2250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12833718#action_12833718 ] 

Ragulan edited comment on AXIS-2250 at 2/15/10 8:43 AM:
--------------------------------------------------------

We have fixed this issue by the following fix:

Modifed the code to get the childNodeName of the NodeList from the server-config.wsdd as follows:

My Sample Code:

server-config.wsdd:
<typeMapping
        xmlns:ns="java:service"
        qname="ns:subPackage"  // decides the childNode name of the NodeList
        type="java:service.Package"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    />
    
<arrayMapping
        xmlns:ns="java:service"
        qname="ns:packages"
        type="java:service.Package[]"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    />


Wsdl:
<wsdl:types>
<schema targetNamespace="java:service" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="service">
	<sequence>
		//element name is the parentNode's Name of the NodeList  (this name is from java class) and type is from wsdd file
		 <element name="packages" nillable="true" type="tns1:packages"/> 
	</sequence>
</complexType>
<complexType name="packages">
	<complexContent>
		<restriction base="soapenc:Array">
			//arrayType is from wsdd file
			<attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:subPackage[]"/>
		</restriction>
	</complexContent>
</complexType>
<complexType name="subPackage">	 // element name is the childNode's Name in the NodeList (this name is from wsdd file)
	<sequence>
		// element name is the inner node of the childNode (this name is from java class)
		<element name="packageName" nillable="true" type="soapenc:string"/> 
	</sequence>
</complexType>
</schema>
</wsdl:types>


Response:
<firstMethodReturn xmlns:ns2="java:service" xsi:type="ns2:service">
<packages xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:Array" soapenc:arrayType="ns2:subPackage[2]">
	<subPackage xsi:type="ns2:subPackage">
		<packageName xsi:type="soapenc:string">First</packageName>
	</subPackage>
	<subPackage xsi:type="ns2:subPackage">
		<packageName xsi:type="soapenc:string">Second</packageName>
	</subPackage>
</packages>
</firstMethodReturn>



Changes Needs to be done:
1)  Change the qname in the typeMapping of the childNode of the NodeList.  This qname is used as the childNode's Name in the NodeList.
	for e.g: 
		In the above sample .wsdd file, i ve changed the qname in the typeMapping  as qname="ns:subPackage".
		So, the childNode's Name in the NodeList will be "subPackage".

2) In org.apache.axis.encoding.ser.ArraySerializer Class, include the below code marked in blue.

	if (!maxOccursUsage) {
            serializeAttr = null;  // since we are putting them here
            context.startElement(name, attributes);
            if (itemQName != null)
                elementName = itemQName;
            else if(componentQName != null)
                elementName = componentQName;
            else 
            	elementName = new QName(name.getNamespaceURI(), componentTypeQName.getLocalPart());
        }


Let us know if somebody have a problem with this solution.

This Fix is done by Team in VERIZON . 

      was (Author: ragulcs):
    We have fixed this issue by the following fix:

Modifed the code to get the childNodeName of the NodeList from the server-config.wsdd as follows:

My Sample Code:

server-config.wsdd:
<typeMapping
        xmlns:ns="java:service"
        qname="ns:subPackage"  // decides the childNode name of the NodeList
        type="java:service.Package"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    />
    
<arrayMapping
        xmlns:ns="java:service"
        qname="ns:packages"
        type="java:service.Package[]"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    />


Wsdl:
<wsdl:types>
<schema targetNamespace="java:service" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="service">
	<sequence>
		//element name is the parentNode's Name of the NodeList  (this name is from java class) and type is from wsdd file
		 <element name="packages" nillable="true" type="tns1:packages"/> 
	</sequence>
</complexType>
<complexType name="packages">
	<complexContent>
		<restriction base="soapenc:Array">
			//arrayType is from wsdd file
			<attribute ref="soapenc:arrayType" wsdl:arrayType="tns1:subPackage[]"/>
		</restriction>
	</complexContent>
</complexType>
<complexType name="subPackage">	 // element name is the childNode's Name in the NodeList (this name is from wsdd file)
	<sequence>
		// element name is the inner node of the childNode (this name is from java class)
		<element name="packageName" nillable="true" type="soapenc:string"/> 
	</sequence>
</complexType>
</schema>
</wsdl:types>


Response:
<firstMethodReturn xmlns:ns2="java:service" xsi:type="ns2:service">
<packages xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:Array" soapenc:arrayType="ns2:subPackage[2]">
	<subPackage xsi:type="ns2:subPackage">
		<packageName xsi:type="soapenc:string">First</packageName>
	</subPackage>
	<subPackage xsi:type="ns2:subPackage">
		<packageName xsi:type="soapenc:string">Second</packageName>
	</subPackage>
</packages>
</firstMethodReturn>



Changes Needs to be done:
1)  Change the qname in the typeMapping of the childNode of the NodeList.  This qname is used as the childNode's Name in the NodeList.
	for e.g: 
		In the above sample .wsdd file, i ve changed the qname in the typeMapping  as qname="ns:subPackage".
		So, the childNode's Name in the NodeList will be "subPackage".

2) In org.apache.axis.encoding.ser.ArraySerializer Class, include the below code marked in blue.

	if (!maxOccursUsage) {
            serializeAttr = null;  // since we are putting them here
            context.startElement(name, attributes);
            if (itemQName != null)
                elementName = itemQName;
            else if(componentQName != null)
                elementName = componentQName;
            else 
            	elementName = new QName(name.getNamespaceURI(), componentTypeQName.getLocalPart());
        }
  
> AXIS array serialization: Incorrect element names of items in a list
> --------------------------------------------------------------------
>
>                 Key: AXIS-2250
>                 URL: https://issues.apache.org/jira/browse/AXIS-2250
>             Project: Axis
>          Issue Type: Bug
>          Components: Serialization/Deserialization
>    Affects Versions: current (nightly)
>         Environment: plattform: i386, OS: WinXP Pro, Java: 1.4.2_06
>            Reporter: Denis Schlesinger
>            Priority: Critical
>         Attachments: beans.zip, Post.zip
>
>
> -Web Service deployed as "wrapped/literal"
> The web service returns a custom bean style class which has an array of another custom bean style class as a member.
> In the WSDL-file the array of the custom type is being described correctly:
> <complexType name="ArrayOf_tns1_EntityTypeBean">
> 	<sequence>
>             <element maxOccurs="unbounded" minOccurs="0" name="item" type="tns1:EntityTypeBean"/>
>         </sequence>
> </complexType>
> But when the Java object is being serialized during runtime the array is being transfered to a list whose member elements DO NOT have the name "item" as expected from the WSDL-file. All members of the list have the same name as the list itself:
> <entities>
>     <entities>
>         ...
>     </entities>
>     <entities>
>           ... 
>     </entities>
>     <entities>
>           ... 
>     </entities>
> </entities>
> But this is expected: 
> <entities>
>     <item>
>         ...
>     </item>
>     <item>
>           ... 
>     </item>
>     <item>
>           ... 
>     </item>
>  </entities>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.