minoccurs=0; nillable="true not interpreted in Web Services

In one of the previous posts I’ve defined a workaround concerning the nillable attribute being ignored when invoking web services using xsd’s defined in the following manner.

Because in bpel you’re not able to define the xsi:nil-attribute at design time, you need to define this manually.

The xsi:nil=true-attribute is the solution to tell web services that this attribute, if empty, needs to be ignored. In this way serialization and deserialization will work, otherwise you will always run into NullPointerException.

What’s the cause of our problem when talking about bpel [metalink Note:403586.1]:
The XSLT transformer used by BPEL was not originally designed to pass xsi:nil attributes.

What’s the proposed solution [metalink Note:403586.1]:
To transfer xsi:nil values from source and target schemas in a transformation, make use of xsl:choose and xsl:when as shown below:

What you could also do is in the web service proxy wizard, which is generated for a given wsdl-document change the serializer-classes. Though this isn’t really the approach you woudl wan’t to consider because now you’re changing generated code, which will be changed when the wizard is run again.

The following important message is shown in your proxy generated classes that urges you to not change the generated code ;o)

// !DO NOT EDIT THIS FILE!// This source file is generated by Oracle tools//
Contents may be subject to change// For reporting problems, use the following//
Version = Oracle WebServices (10.1.3.3.0, build 070610.1800.23513)

What you can do, on your own responsibility, is to change the literal_serializer classes which were generated for each object used in your webservices payload. You need to change the setNullable-method for each attribute from ‘false’ to ‘true':

if (
matchQName(elementName, ns1_adresId_QNAME) )
{
myns2_string__java_lang_String_String_Serializer.setNullable( false );

if (
matchQName(elementName, ns1_adresId_QNAME) )
{
myns2_string__java_lang_String_String_Serializer.setNullable( true);

Another possibility is to create a Service Request and define an Enhancement Request so this manual tweaking isn’t necessary anymore in the future … that’s what I’m doing as well/