Web Service validation error

1
Hi, I have published a web server and in the earlier post on forum I read that we can't have validations on attributes at entity level as this will give errors while importing that web service. Currently I am facing the same issue, in one of the entity I have validation on attributes and I don't want to remove them as this will mess up the entire application and when I commit that entity through web service it gives me web service exception error. I tried to make a test import by removing those validation on attributes and commit was successful and web service worked fine. But as soon as I put those validations back it gives me error. Please can anyone help me out how to solve this issue. I don't want to remove those validations, is there any other way to make this work? Thanks in advance..!!
asked
2 answers
0

Can you point at the earlier post on the forum? I'm not entirely sure I understand your problem. But it looks like you have validation on an entity in your domain model and you're also exposing this entity and the actual values do not match with your validation rules, am I correct? In this case you could create some API entity instead and expose that in your web service. An alternative could be to map to your attribute using a microflow to avoid setting incorrect values.

answered
0

Hi Mohammed, we're facing the same behavior and solved it by creating a webservice module with temporary objects. These temporary objects are exposed in our webservice and after a webservice call we try to map the temporary object to a real object. Before we do that, we'll do all sort of validations. If the call is not correct, we send feedback back to the caller with a long string of validations results. We use this approach in all kinds of webservice, because it's much more save and you're in control.

I would avoid exposing real objects in a webservice, because you want to validate things first, before you create objects in your database. This is only when you do complex things, for simple operations you can always expose your real objects.

answered