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 "Adi (JIRA)" <ax...@ws.apache.org> on 2014/12/28 00:13:13 UTC
[jira] [Commented] (AXIS-335) none SOAP Array Deserialization in
BeanDeserializer incl. fix
[ https://issues.apache.org/jira/browse/AXIS-335?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14259515#comment-14259515 ]
Adi commented on AXIS-335:
--------------------------
Hi ,
I am facing same issue .
Any solution of this issue.
> none SOAP Array Deserialization in BeanDeserializer incl. fix
> -------------------------------------------------------------
>
> Key: AXIS-335
> URL: https://issues.apache.org/jira/browse/AXIS-335
> Project: Axis
> Issue Type: Bug
> Components: Serialization/Deserialization
> Environment: Operating System: Other
> Platform: Other
> Reporter: Oliver Schmitz
> Assignee: Glen Daniels
>
> Hi
> I am calling a SOAP service which sends messages containing elements with
> multiple (as I have been told) non SOAP Arrays , which looks as follows:
> <elem>
> <arr1>xxx</arr1>
> <arr2>xxx</arr2>
> <arr1>xxx</arr1>
> <arr2>xxx</arr2>
> <arr1>xxx</arr1>
> <arr2>xxx</arr2>
> <arr1>xxx</arr1>
> <arr2>xxx</arr2>
> </elem>
> The BeanDeserializer in the current implementation assumes, that multiple non
> SOAP arrays elements appear sequentially as in:
> <elem>
> <arr1>xxx</arr1>
> <arr1>xxx</arr1>
> <arr1>xxx</arr1>
> <arr1>xxx</arr1>
> <arr2>xxx</arr2>
> <arr2>xxx</arr2>
> <arr2>xxx</arr2>
> <arr2>xxx</arr2>
> </elem>
> This is expressed in the fact, that the IndexCounter inside the
> org.apache.axis.encoding.ser.BeanDeserializer is reset to -1 each time a childs
> qname is different from the previous childs qname. In the first case stated
> above only one array element is filled instead of four for each array,
> containing the last value in the list.
> I do not have very good knowledge about the SOAP protocol, but a friend of mine
> told me, that both ways should be XML conform.
> So I would like to offer a fix for this problem.
> Instead of using the prevQName (which can be removed) I use a Hashtable to
> store the array indizes for each child Array. The Hash is initialized in the
> onStartElement method.
> It now looks like :
> ....
> public void onStartElement(String namespace, String localName,
> String prefix, Attributes attributes,
> DeserializationContext context)
> throws SAXException {
> // Reset Array Indexes
> collectionIndexHash = new Hashtable() ;
> ....
> Further I removed the handling of the prevQName Attribute
> // The collectionIndex needs to be reset for Beans with multiple arrays
> /* if ((prevQName == null) || (!prevQName.equals(elemQName))) {
> collectionIndex = -1;
> }
> prevQName = elemQName;
> */
> finally I changed the onStartChild method. This may not be the most efficient
> Method, but it works.
> ....
> // Register value target
> if (propDesc.isWriteable()) {
> // If this is an indexed property, and the deserializer we found
> // was NOT the ArrayDeserializer, this is a non-SOAP array:
> // <bean>
> // <field>value1</field>
> // <field>value2</field>
> // ...
> // In this case, we want to use the collectionIndex and make sure
> // the deserialized value for the child element goes into the
> // right place in the collection.
> if (propDesc.isIndexed() && !(dSer instanceof ArrayDeserializer)) {
> Integer indexHolder = (Integer) collectionIndexHash.get
> (localName);
> if ( indexHolder == null ) {
> collectionIndex = 0 ;
> }else{
> collectionIndex = indexHolder.intValue()+1;
> }
> collectionIndexHash.put(localName , new Integer
> (collectionIndex));
> dSer.registerValueTarget(new BeanPropertyTarget(value,
> propDesc, collectionIndex));
> } else {
> // If we're here, the element maps to a single field value,
> // whether that be a "basic" type or an array, so use the
> // normal (non-indexed) BeanPropertyTarget form.
> collectionIndex = -1;
> dSer.registerValueTarget(new BeanPropertyTarget(value,
> propDesc));
> }
> }
> ....
> Here is a diff against Version 1.51
> cvs -z9 diff -w BeanDeserializer.java (in directory C:\apache\xml-
> axis.head\java\src\org\apache\axis\encoding\ser\)
> Index: BeanDeserializer.java
> ===================================================================
> RCS file: /home/cvspublic/xml-
> axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v
> retrieving revision 1.51
> diff -w -r1.51 BeanDeserializer.java
> 79a80,81
> > import java.util.Hashtable;
> >
> 96c98
> < protected QName prevQName;
> ---
> > // protected QName prevQName;
> 103a106,107
> > protected Hashtable collectionIndexHash = null ;
> >
> 161a166
> >
> 198c203
> < if ((prevQName == null) || (!prevQName.equals(elemQName))) {
> ---
> > /* if ((prevQName == null) || (!prevQName.equals(elemQName))) {
> 202c207
> <
> ---
> > */
> 282c287,293
> < collectionIndex++;
> ---
> > Integer indexHolder = (Integer) collectionIndexHash.get
> (localName);
> > if ( indexHolder == null ) {
> > collectionIndex = 0 ;
> > }else{
> > collectionIndex = indexHolder.intValue()+1;
> > }
> > collectionIndexHash.put(localName , new Integer
> (collectionIndex));
> 328a340,342
> > // Reset Array Indexes
> > collectionIndexHash = new Hashtable() ;
> >
> 335a350
> >
> I would like to see something like this implemented in 1.0 (because I need it
> to call the service :-).
> regards
> Oliver Schmitz
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org