Work around identified!

Only fails if binding style=rpc", set it to style="document"  problem
goes away. 



> -----Original Message-----
> From: Richard Wallis [mailto:[EMAIL PROTECTED] 
> Sent: 07 March 2005 13:27
> To: [email protected]
> Subject: Serialise with MinOccurs=0
> 
> In axis-1.2RC2, I am having a general problem returning 
> complex messages with optional elements.  
> 
> To try and track down the problem I have created a simple 
> test setup to pass a simple message and return an identical 
> [but differently named] message where one of the elements is 
> optional (ie. MinOccurs=0)
> 
> <xsd:complexType name="TestUserResponse">
>       <xsd:sequence>
>               <xsd:element name="VisibleUserIdentifierType"
> type="key:IdentifierType"/>
>               <xsd:element name="VisibleUserIdentifier"
> type="xsd:string" minOccurs="0" />
>               <xsd:element name="Desired" type="key:Desired"/>
>       </xsd:sequence>
> </xsd:complexType>
> 
> wsdl2Java provides me with a TestUserResponse.java which is 
> the return type for my TestLookupSoapBindingImpl class.  If I 
> correctly populate all the elements of the TestUserResponse 
> object that I return, thus:
>  
> ret.setVisibleUserIdentifierType(lookupUserRequest.getVisibleU
> serIdentif
> ierType());
>  
> ret.setVisibleUserIdentifier(lookupUserRequest.getVisibleUserI
> dentifier(
> ));
>       ret.setDesired(lookupUserRequest.getDesired());
> Everything is fine.
> 
> If I don't want a  'VisibleUserIdentifier' element which the 
> minOccurs="0" should allow me to do, I either don't call 
> 'setVisibleUserIdentifier()' or call it with a null value.  
> In either case the service returns null to the client thus:
>    <soapenv:Body>
>       <ns1:lookResponse
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
> xmlns:ns1="urn:TestLookup">
>          <lookUpReturn xsi:type="ns2:TestUserResponse" xsi:nil="true"
> xmlns:ns2="http://schemas.talis.com/ws/Keystone"/>
>       </ns1:lookResponse>
>    </soapenv:Body></soapenv:Envelope>
> 
> I presume that the serialiser is failing to serialise a null 
> element correctly.
> 
> Any idea how I can make it serialise a null element, or 
> instruct it not to try?
> 
> Regards,
>       Richard
>  
> 
>  
> 
> 
> 
> 

Reply via email to