cancel
Showing results for 
Search instead for 
Did you mean: 

Web Service parameter

Former Member
0 Kudos

Hello everybody,

I hope this is right forum...

I have got a problem related to parameters to be passed from the web service (I'm using developer studio 7.0.1 and java 1.4.2)

I have created a web service with a incoming parameter that is a class type parameter, nor a primitive type or list of primitive type. This class have some filed, some of which have type of boolean and float.

When I call the web service (i.e. with Web ServiceNavigator) the boolean and float fields are initialized to "false" and 0.0 respectively.

If user don't fill these fields or leave it blank, they are then passed to serialization/deserializtion process with default values; so the program can't recognized if 0.0 value is filled by the user or not.

With String type I haven't prooblem because I can use empty String (default value) to see if user have filled a field.

Can I set initial/default value for incoming/outcoming parameters that are not primitive type?

The class constructor modified the field, so I can set them to a predefined value using to establish if user have filled a field, but in anyway the follow serialization/deserialization process overwrite this update..

what can I do?

Otherwise, can I prevent initial/default value process?

thanks in advance and apologize for my english!

Cristian

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hi,

You are correct in that the WSN calls the vanilla constructors of the fields. Although your users can use the "null" check instead of passing the value.

The default values shouldn't be added by WSN for objects (I am not sure if it is an issue).

If you really need to remove the default error here is a sneaky, underhanded way of doing it. Just extend the Boolean and Float classes - and make your own classes. Add a constructor (with no parameters) and assign the value to "null".

That's should fix the issue. If not then it is a WSN issue and you can fix it during the Web Service Consumption rather than in the Web Service.

Hope I am making some sense.:)

Thanks.

p256960.

Former Member
0 Kudos

Ok, now it is clear!!

thanks very much!

Cristian

0 Kudos

Hi,

I have used this solution in my code.

In the Web Service Parameter - please use "Boolean" and "Float" instead of booean and float.

This will mean that is the user does not enter any value for those fields then the web service will pass null instead of 0.0 and false.

Then whereever you have consumed this web service - please add code that will first check if the incoming parameter is null first.

If it is null - user did not enter anything

else user has entered something.

You can use the booleanValue() from Boolean class and floatValue() methods that return the boolean and float types respectively.

It may be a big change in your coding (I can guess because I had the same issue). But it will work out in the end.

Thanks. I hope this will help you.

p256960

Former Member
0 Kudos

Thanks p256960 for the reply!

I have tried this solution but when I test the WS via the Web Service Navigator, the Float field was initiliazed to 0.0 value (Boolean to "false" value) and then pass these value to web service engine

Maybe it is only a Web Service Navigator issue? That is Navigator calls default costructors of class fields and not set them to null?

thanks!

Cristian