You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Monica Ferrero <mf...@accelrys.com> on 2008/04/25 13:19:42 UTC

Optional elements of complex type must be present just empty


Hi!

I have wsdl first service, snippet below, with a  type getxxx (request
parameters for the corresponding getxxx method) which contains two optional
string arrays. If the optional string arrays are not present CXF fails. If
they are present but empty, things work fine.
Why is this? How can I allow for the array elements not to be present at
all in the SOAP message?
I'm using CXF 2.0.4.

So

<getxxx xmlns="http://myservice.bbb.aaa.com/
"><id>1</id><var1>0</var1><var2>5</var2></getxxx>

fails, but

<getxxx xmlns="http://myservice.bbb.aaa.com/
"><id>1</id><array1/><array2/><var1>0</var1><var2>5</var2></getxxx>

is ok.

Thanks for you help,

Monica

wsdl:
            <xsd:complexType name="StringArray">
                <xsd:sequence>
                    <xsd:element name="item" type="xsd:string" minOccurs=
"0" maxOccurs="unbounded"/>
                </xsd:sequence>
            </xsd:complexType>

            <xs:element name="getxxx" type="ps:getxxx"/>
            <xs:complexType name="getxxx">
                <xs:sequence>
                    <xs:element name="id" type="xs:int"/>
                    <xs:element maxOccurs="1" minOccurs="0" name="array1"
type="ps:StringArray"/>
                    <xs:element maxOccurs="1" minOccurs="0" name="array2"
type="ps:StringArray"/>
                    <xs:element name="var1" type="xs:int"/>
                    <xs:element name="var2" type="xs:int"/>
                </xs:sequence>
            </xs:complexType>


Output:

Encoding: UTF-8
Headers: {cache-control=[no-cache], content-type=[text/xml; charset=UTF-8],
connection=[keep-alive], host=[localhost:8080], soapaction=[""],
transfer-encoding=[chunked], accept=[*], user-agent=[Java/1.6.0_03],
pragma=[no-cache]}
Messages:
Message:

Payload: <soap:Envelope xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header/>
<soap:Body><getxxx xmlns="http://myservice.bbb.aaa.com/
"><id>1</id><var1>0</var1><var2>5</var2></getxxx></soap:Body>
</soap:Envelope>
--------------------------------------
25-Apr-2008 11:40:42 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Application has thrown exception, unwinding now: null