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 "Boris Georgiev (JIRA)" <ji...@apache.org> on 2008/01/22 19:00:36 UTC

[jira] Commented: (AXIS2-3341) Marshaling arrays and lists seems to be wrong

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

Boris Georgiev commented on AXIS2-3341:
---------------------------------------

Rich,

Before we start any conversation about this, let me tell you that neither
Sun's JAX-WS RI, nor Websphere's Webservices Option Pack (which uses Axis2
as webservice engine) works this way.

Referring to the same JAXB 2.0 5.5.2 (not 5.2.2) quote: "A collection
property may take the form of an indexed property or a list property".
Notice the word may, not must. Notice, also that the specification says
nothing about the array properties, which by default are to be treated as
simple properties. I have used JAXB up to day on objects, containing only
list properties on their collections. JAXB always handled them correctly
and never complained that it needs an indexed property. And serializing an
object's handle in an XML document does not make any sense, as it becomes
completely meaningless, outside the JVM.

I also downloaded the Axis2 source code. There I saw that the jax-ws
message receiver serializes the return result on a single object and wraps
it in the response element. This is all proprietary in the message receiver
and even the @ResponseWrapper annotation is completely ignored. The
generated WSDL completely ignores all the JAXB annotations and there were
some other defects. I made a local fix, however I'm not quite familiar with
the Axis2 architecture roadmap and I'm not sure that I did it right.

Looking at Axis2 JAX-WS implementation I can observe many problems. This
one is the big roadblock for me. The forementioned JAX-WS implementations
work way better. So I really wonder is the Axis2 community really
interested to work on JAX-WS implementation at all. For now, I no longer
consider Axis2 as my webservice engine.

If I can see any architecture dociments, to make sure that I'm on the right
track I can become a contributor and help you with this. Axis1 was a great
webservice engine and I used it for a long time. However, I firmly believe
in the industrial strandards as a way to protect investments, so a working
JAX-WS engine is my goal and I cannot accept your explanation.

Regards,
Boris Georgiev
Sun Certified Enterprise Architect.




                                                                           
             "Rich Scheuerle                                               
             (JIRA)"                                                       
             <ji...@apache.org>                                          To 
                                       boris.georgiev@pfpc.com             
             01/18/2008 03:40                                           cc 
             PM                                                            
                                                                   Subject 
                                       [jira] Resolved: (AXIS2-3341)       
                                       Marshaling arrays and lists seems   
                                       to be wrong                         
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           





     [
https://issues.apache.org/jira/browse/AXIS2-3341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rich Scheuerle resolved AXIS2-3341.
-----------------------------------

    Resolution: Won't Fix

Boris,

After some investigation of the code, I think this request falls into the
"Won't Fix" category.
For JAX-WS wrapper cases, the JAX-WS code constructs a JAXB object and
delegates to the JAXB marshalling engine.
In your failing cases, the JAXB wrapper objects have invalid JAXB
Collection Properties.

Please read the two scenarios below and the suggested change to the user
code.

Thanks,
Rich

------------------------------------------
Scenario 1:
    @WebResult(name = "complexListReturn", targetNamespace = "
http://jaxws.samples.pfpc.net")
    @ResponseWrapper(className =
"net.pfpc.samples.jaxws.ComplexListResponse" ,
localName="complexListResponse", targetNamespace="
http://jaxws.samples.pfpc.net")
             public List<WSUser> getComplexList();

In this case, the response wrapper locates a JAXB bean which contains a
valid "JAXB Collection Property".
The sent message matches your expectation.

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "simpleListReturn"
})
@XmlRootElement(name = "simpleListResponse")
public class SimpleListResponse {
             @XmlElement(name="simpleListReturn", namespace="
http://jaxws.samples.pfpc.net", required=false)
    protected List<String> simpleListReturn = new
java.util.ArrayList<String>();

             public List<String> getSimpleListReturn() {
                         return simpleListReturn;
             }

             public void setSimpleListReturn(List<String> simpleListReturn)
{
                         this.simpleListReturn = simpleListReturn;
             }

}

--------------------------------------
Scenario 2: (The scenario for this JIRA)

    @WebMethod
    @WebResult(name = "simpleArrayReturn", targetNamespace = "
http://jaxws.samples.pfpc.net")
    @ResponseWrapper(className =
"net.pfpc.samples.jaxws.SimpleArrayResponse")
             public String[] getSimpleArray();

In this scenario the response wrapper DOES NOT contain a valid JAXB
Collection Property.
Therefore JAXB marshals the String[] as atomic data (hence the xmlist like
instance data).

public class SimpleArrayResponse {
             @XmlElement(name="simpleArrayReturn", namespace="
http://jaxws.samples.pfpc.net", required=false)
    protected String[] simpleArrayReturn;

             public String[] getSimpleArrayReturn() {
                         return simpleArrayReturn;
             }

             public void setSimpleArrayReturn(String[] simpleArrayReturn) {
                         this.simpleArrayReturn = simpleArrayReturn;
             }

}

User Solution to scenario 2:
---------------------------------------
According to JAXB 2.0 5.2.2.1, a JAXB Collection Property that is backed by
an array must be in the form of an "indexed property".
In addition to the array setter/getter, you must have an indexed
setter/getter and length getter.  For example,

public Type [] getdI();
public void setId (Type [] value);
public void setId(int index, Type value);
public Type getId(int index);
public int getIdLength();

This makes sense, since the marshalling engine will need to get and set
discrete items.  It cannot do this properly without the
indexed setter/getter fields.





Looks like, for each element in the array is called the method toString(),
then all of the array elements are separated by spaces and finally all the
result is placed in a single xml element.
needs to be in its own element. Then, calling toString() may work for a
simple type, it is completely meaningless for a complex types, as it is
usually the string representation of the object's handle.
it for the return types, I have not tested it for arrays in the input
paparameters.
how?
service name is "GenericService" there are four methods, returning: array
of string, array of a complex type, list of string and a list of a complex
type.
observed and as they need to be for arrays. For lists, the messages are the
same.
project, without the axis2 libraries.

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




The contents of this email are the property of the sender. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender.


> Marshaling arrays and lists seems to be wrong
> ---------------------------------------------
>
>                 Key: AXIS2-3341
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3341
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: jaxws
>    Affects Versions: 1.3, 1.2
>         Environment: JDK 1.5 and Geronimo 1.1 , also Websphere 6.1
>            Reporter: Boris Georgiev
>            Assignee: Rich Scheuerle
>         Attachments: jaxws-axis2.zip, return_messages.txt
>
>
> The problem seems to be about incorrect marshaling of arrays and lists. Looks like, for each element in the array is called the method toString(), then all of the array elements are separated by spaces and finally all the result is placed in a single xml element.
> As I see, according to the schema in the WSDL, every element of the array needs to be in its own element. Then, calling toString() may work for a simple type, it is completely meaningless for a complex types, as it is usually the string representation of the object's handle.
>  
> I get the same result with or without response wrapper objects. I observe it for the return types, I have not tested it for arrays in the input paparameters.
> Can I use some other databinding mechanism, in order to avoid this and how?
> To demonstarate it, I have created a simple web service project. The service name is "GenericService" there are four methods, returning: array of string, array of a complex type, list of string and a list of a complex type.
> The attached file return_messages.txt contains the messages: as they are observed and as they need to be for arrays. For lists, the messages are the same.
> Te attached file jaxw-axis2.zip contains the sample geronimo/eclipse project, without the axis2 libraries.

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


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