ianroberts wrote:
> 
> greenstar wrote:
>> Consider this example client:
>> 
>> @WebServicetargetNamespace="http://foobar.com";)
>> public interface Test {
>> 
>>     @WebMethod(operationName = "x")
>>     public String x(
>>             @WebParam(name = "values") String[] values);    
>> }
>> 
>> Using JaxWsProxyFactoryBean, the array argument gets marshalled to:
>> 
>> <values>1</values>
>> <values>2</values>
>> <values>3</values>
>> 
>> I would like to marshal it like this:
>> 
>> <values>
>>   <value>1</value>
>>   <value>2</value>
>>   <value>3</value>
>> </values>
>> 
>> This seems like this would make it much easier to determine between an
>> empty
>> array and "not provided" (ie: null) at the other end.  When I send an
>> empty
>> array, it gets unmarshalled to a null at the other end because it can't
>> tell
>> the difference.
>> 
>> I can make a wrapper object and things work fine, but shouldn't the
>> standard
>> simple case using arrays work in a safer way?  What am I missing?
> 
> I think this is what the @XmlElementWrapper JAXB annotation does, but to 
> use that you'd have to create the request wrapper bean explicitly 
> (either manually or with the wsgen tool from Java 6 or Metro) and then 
> annotate the values property in that with @XmlElementWrapper.
> 
> I guess the alternative would be to create your wrapper object and then 
> register a type adapter to use your wrapper object in place of String[].
> 
> Neither option is particularly elegant :-(
> 

Yeah, if I make a wrapper object I have many more options.  However I am
simply questioning the "default" behavior of Array types not being wrapped
hence making it difficult to distinguish between empty and null (not
provided).  I was hoping that maybe I was missing something and there was a
way I could control this  without making a wrapper object.

-- 
View this message in context: 
http://www.nabble.com/Marshalling-arrays%3A-tp17653605p17658507.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to