tags:

views:

254

answers:

1

I'm creating a web services and generating a contract (WSDL) with Axis2 like a POJO web service which is in turn giving me an output like this

<xs:element minOccurs="0" name="acHolderName" nillable="true" type="xs:string"/>

Whereas the required one is this <xs:element minOccurs="0" name="acHolderName" type="xs:string"/>

Is there any annotation which can get me do this or any other better implementation??

+1  A: 

The nil attribute is documented here.

From an java object serialization point of view it allows an object attribute to have a NULL value and still be a valid XML document. This is the default way to represent Java objects in an XML schema, because objects attributes are not forced to be populated in Java.

If you want more control over the WSDL you need to consider using something like JAXWS. Problem here is that support form this technology is not very mature in Axis2, and it's more complicated to deploy, in my opinion.

If you want absolute control over your WSDL (using it as an interface specification) it is probably best to use it to generate the Java code instead of hoping your java will conform to someone else's specification.

Mark O'Connor
If you're using Apache stuff with JAX-WS, you're probably better off with Apache CXF.
R. Bemrose
Really appreciate for your time in replying :) But the whole issue here its a Top-Down Approach. Like I said there's a WSDL which has the latter XML tag and I'm supposed to use that ALONE. To ANALYZE I generated WSDL (Note: Followed Bottom Up to check WHAT WENT WRONG??) Generated one had nillable="true" for all the fields in POJO. My question here is "Do I have to implement anything in the POJO so that when I'm generating a WSDL it automatically omits the nillable="true"?"
Sandeep
Can't be done using POJO based web services, far as I know. The nil attribute is designed to represent a NULL value for the object.Of course the minOccurs="0" attribute could also represent a NULL value and this is what leads to confusion in the web service rendition of Java objects... I don't know why there are two mechanisms.... Blame the XML Schema specification :-(
Mark O'Connor
Either generate the interface code from the WSDL or use a tech like JAX-WS that allows you more control over the generated WSDL from the java code
Mark O'Connor