users@jax-ws.java.net

Re: Problem with string arrays containing nulls

From: Vivek Pandey <Vivek.Pandey_at_Sun.COM>
Date: Wed, 07 Feb 2007 15:52:10 -0800

After talking to jaxb experts - there is no jaxb annotation that you can
put on method parameters to achieve such behaviour. This is something
that can be handled by JAXWS, where it can generate
@XmlElement(nillable="true") in the wrapper bean on the property.

However we would need to verify whether such change will be
non-compliant w.r.t. generated code from such schema by wsimport.

Please go ahead and report and issue at
http://jax-ws.dev.java.net/servlets/ProjectIssues.

-vivek.

Vivek Pandey wrote:
> The generated schema look ok to me. String[] is mapped to and it seems
> correct as per JAXB schema.
>
> <xs:element name="return" type="xs:string" maxOccurs="unbounded"
> minOccurs="0"/>
>
> Which look ok as per JAXB spec and expectedly at runtime the null
> element is ignored. So your analysis is correct.
> I am wondering if there is any jaxb annotation or some mechanism to
> generate such schema. Ccing it to users_at_jaxb alias.
>
> -vivek.
>
>
>
>
>
> Egor Samarkhanov wrote:
>> Hi!
>>
>> I have a problem with string arrays containing nulls (WSIT):
>>
>> Here is my simple service:
>>
>> @WebService
>> public class MyServiceImpl
>> {
>> @WebMethod()
>> public String[] testStringArray( String[] s )
>> {
>> return new String[] {"s","",null};
>> }
>> }
>>
>> WSIT generates the following WSDL types for it:
>>
>> <xs:schema xmlns:tns="http://wsitproto/"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"
>> targetNamespace="http://wsitproto/">
>> <xs:element name="testStringArray" type="tns:testStringArray"/>
>> <xs:element name="testStringArrayResponse"
>> type="tns:testStringArrayResponse"/>
>> <xs:complexType name="testStringArray">
>> <xs:sequence>
>> <xs:element name="arg0" type="xs:string"
>> maxOccurs="unbounded" minOccurs="0"/>
>> </xs:sequence>
>> </xs:complexType>
>> <xs:complexType name="testStringArrayResponse">
>> <xs:sequence>
>> <xs:element name="return" type="xs:string"
>> maxOccurs="unbounded" minOccurs="0"/>
>> </xs:sequence>
>> </xs:complexType>
>> </xs:schema>
>>
>> I created WCF client and tried to invoke the service with the new
>> String[] {"s","",null} parameter,
>> but my service received only two first values (only {"s",""}). The
>> last null string is missed.
>>
>> I examined SOAP envelopes and they look accordingly:
>>
>> Inbound message:
>>
>> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
>> <s:Header/>
>> <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>> <testStringArray xmlns="http://wsitproto/">
>> <arg0 xmlns="">s</arg0>
>> <arg0 xmlns=""/>
>> </testStringArray>
>> </s:Body>
>> </s:Envelope>
>>
>> Outbound message:
>>
>> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
>> <S:Body>
>> <ns2:testStringArrayResponse xmlns:ns2="http://wsitproto/">
>> <return>s</return>
>> <return></return>
>> </ns2:testStringArrayResponse>
>> </S:Body>
>> </S:Envelope>
>>
>> As I understand that's because elements are not marked as
>> nillable="true" in WSDL.
>> I think the correct WSDL types would be as follows:
>>
>> <xs:schema xmlns:tns="http://wsitproto/"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"
>> targetNamespace="http://wsitproto/">
>> <xs:element name="testStringArray" type="tns:testStringArray"/>
>> <xs:element name="testStringArrayResponse"
>> type="tns:testStringArrayResponse"/>
>> <xs:complexType name="testStringArray">
>> <xs:sequence>
>> <xs:element name="arg0" type="xs:string"
>> maxOccurs="unbounded" minOccurs="0" nillable="true"/>
>> </xs:sequence>
>> </xs:complexType>
>> <xs:complexType name="testStringArrayResponse">
>> <xs:sequence>
>> <xs:element name="return" type="xs:string"
>> maxOccurs="unbounded" minOccurs="0" nillable="true"/>
>> </xs:sequence>
>> </xs:complexType>
>> </xs:schema>
>>
>> (note the nillable attributes)
>>
>> And the question is how can I make WSIT generate and correctly handle
>> nillable types in WSDL?
>>
>>
>> ----
>> Egor
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jax-ws.dev.java.net
>> For additional commands, e-mail: users-help_at_jax-ws.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jax-ws.dev.java.net
> For additional commands, e-mail: users-help_at_jax-ws.dev.java.net
>