Question

Ok. The title really says it all.

I have a extremely large SOAP server I'm calling in a java application. To make my life easier I've been using wsimport to generate the source and jar for the service. I just ran into a problem. All the xsd:int types in the wsdl are being parsed as int types in the java code when I need them as Integer types. Reason for this is some of the int's i need to set as null, but since int types can't be null I can't do that.

I am currently going through and hand changing the fields, but I want to know if there is a easier way to do it through a agrument to the wsimport command

Here is my current wsimport command. Thanks

wsimport.exe -d E:\ServiceWSBuild -p com.example.wsdl -s E:\Service\src -verbose http://wsdl.example.com/?wsdl

Here is also a example of one of the custom types that does this:

 <xsd:complexType name="SubPackageSell">
  <xsd:complexContent>
   <xsd:extension base="tns:APIObject">
  <xsd:sequence>
   <xsd:element name="sp" type="tns:SubPackage"/>
   <xsd:element name="value" type="xsd:int"/>
   <xsd:element name="days" type="xsd:int"/>
   <xsd:element name="date" type="xsd:string"/>
   <xsd:element name="combine" type="xsd:boolean"/>
  </xsd:sequence>
   </xsd:extension>
  </xsd:complexContent>
 </xsd:complexType>
Was it helpful?

Solution

For elements, specify minOccurs="0" and wsimport should generate a java.lang.Integer instead of a primitive int. The default values for minOccurs and maxOccurs is 1, which is why you are getting primitive ints. For example:

<xsd:element name="value" type="xsd:int" minOccurs="0"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top