Thomas,

I faced the same problem some time ago. It seems to be a bug (I reported
it). Try this to update the TypeDesc. In my case this solved the
problem:

  /**
   * Updates the type description of an Axis generated binding class. 
   * With setting the MinOccurs value to zero the xsi:nil elements
disappear while serializing. 
   * Otherwise the generated SOAP body is not a valid instance document.
   *
   * @param clazz the Axis binding class which has to be updated
   * @throws NoSuchMethodException
   * @throws InvocationTargetException
   * @throws IllegalAccessException
   */
  public static void updateClassTypeDesc(Class clazz) throws
NoSuchMethodException, InvocationTargetException, IllegalAccessException
{

    // Using the reflection API to find the getter-method getTypeDesc
    Method getTypeDescMethod = clazz.getMethod("getTypeDesc", new
Class[] {});
    TypeDesc td = (TypeDesc) getTypeDescMethod.invoke(null, null);

    // Iterate through all elements and set minOccurs() to zero for each
element
    FieldDesc[] fds = td.getFields();
    for (int i = 0; i < fds.length; i++) {
      ElementDesc ed = (ElementDesc) fds[i];
      ed.setMinOccurs(0);
    }
  }

Yves

On Mon, 2004-07-26 at 14:41, Dorner Thomas wrote:
> Thank you Yves for your fast reply,
> 
> my WSDL looks like this:
> 
>   <schema elementFormDefault="qualified"
> targetNamespace="http://xml.apache.org/xml-soap";
> xmlns="http://www.w3.org/2001/XMLSchema";>
>    <complexType name="mapItem">
>     <sequence>
>      <element name="key" nillable="false" type="xsd:anyType"/>
>      <element name="value" nillable="false" type="xsd:anyType"/>
>     </sequence>
>    </complexType>
>    <complexType name="Map">
>     <sequence>
>      <element maxOccurs="unbounded" minOccurs="0" name="item"
> type="apachesoap:mapItem"/>
>     </sequence>
>    </complexType>
>   </schema>
> 
> 
> When I generate my classes from this wsdl, it should not be possible to send
> a value that is null!?
> 
> Thanks Tomi
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Yves Langisch [mailto:[EMAIL PROTECTED]
> Gesendet: Montag, 26. Juli 2004 14:39
> An: axis
> Betreff: Re: Check if parameter is null ?
> 
> 
> Thomas,
> 
> Do you mean that an Axis client (wsdl2jave) sends xsi:nil="true" altough
> the wsdl denies it?
> 
> Yves
> 
> On Mon, 2004-07-26 at 14:32, Dorner Thomas wrote:
> > Hi all, 
> >  
> > is it possible to let AXIS check if a parametervalue is == null?
> >  
> > It shouldn t be possible for the client to send a nillable value.
> > But set the nillable="false" in the wsdl before generating my classes
> > have no effect.
> >  
> > I would like to see something like a SOAP-Fault - parameter xxx is
> > nill!
> >  
> > Have someone a hint for me?
> >  
> > Thanks Tomi

Reply via email to