users@jaxb.java.net

Re: Problem with string arrays containing nulls

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Thu, 08 Feb 2007 15:29:49 -0800

I think this is really a JAXB/JAX-WS integration issue. There's really
nothing users can do. We'll just have to fix this on our side.

Egor Samarkhanov wrote:
> Hi !
>
> Thanks for the answer, Vivek.
>
> However, I'm a bit confused as I thought WSIT is intended to
> enable interoperability with WCF. I know that the interoperability
> implies implementation of some complex features like reliable
> messaging and security features, but it might be useless if
> I can't even pass arrays between WCF client and WSIT service.
>
> Probably I'm missing something sine I'm new to WSIT. I will look
> further for any possible solution, but I haven't experienced
> such problems with WCF<->XFire integration, for example. I just
> hope you can point me to some resources/documentation describing
> how to customize schema types of generated WSDL documents in
> code-first web services development.
>
> Thanks again,
>
> Egor.
>
> Wednesday, February 7, 2007, 10:09:05 PM, you wrote:
>
> VP> The generated schema look ok to me. String[] is mapped to and it seems
> VP> correct as per JAXB schema.
>
> VP> <xs:element name="return" type="xs:string"
> VP> maxOccurs="unbounded" minOccurs="0"/>
>
> VP> Which look ok as per JAXB spec and expectedly at runtime the
> VP> null element is ignored. So your analysis is correct.
>
> VP> I am wondering if there is any jaxb annotation or some
> VP> mechanism to generate such schema. Ccing it to users_at_jaxb alias.
>
> VP> -vivek.
>
>
>
>
>
> VP> 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
>>>
>>>
>
> VP> ---------------------------------------------------------------------
> VP> To unsubscribe, e-mail: users-unsubscribe_at_jax-ws.dev.java.net
> VP> For additional commands, e-mail: users-help_at_jax-ws.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com