Reputation: 137
I have the following problem. I want to make web service, which have a lot of parameters for input. Some of them are Double type. The thing is that some of doubles are not necessary and can be passed to my service as empty tags, like
<param xsi:type="xsd:double"></param>
WebLogic, therefore, before turning to my code tries to parse that double and I get
<faultstring>empty String</faultstring>
response with exception in it
<bea_fault:stacktrace xmlns:bea_fault="http://www.bea.com/servers/wls70/webservice/fault/1.0.0">java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1011)
at java.lang.Double.parseDouble(Double.java:540)
So my main question is, how can I get such empty tags as null into Double variable? Or how can I specify that empty value before WebLogic tries to parse it? Thank you in advance!
Upvotes: 3
Views: 2188
Reputation: 36
Please look into your XSD where the Message structure is defined. Focus on two different yet special attributes that can be set for any element in the XSD for message format. these are : minOccurs and nillable. The answer to your problem lies in setting the nillable attribute to "true" (which is false by default.)
Lets see what nillable means, nillable value T/F signifies that whether an element can have an empty value(empty String) or not.
So, if nillable is set as true as
<element name="anyElement" nillable="true"/> in your XSD then that element can be like these <anyEement></anyElement> Or <anyElement/> in your SOAP Request/Response.
but if nillable is set as false (which is the by default it is) then you can expect the error you are getting right now.
I hope it helps. Thanks.
Upvotes: 1