Question
CPS foundation
RU
Last activity: 11 Mar 2021 9:20 EST
Activity, SOAP service, how to properly filter the transmitted data so that only 2 out of 12 fields change
Hello!
I have a soap service. The service should make changes to the vehicle object (for example, the color of the car was mistakenly assigned, red instead of blue, and the wheel size was 18 instead of 17).I transferred to the service the data: the key "CarId", the color is "Blue", the size of the wheels is "18", in the service I still have ten parameters (brand, engine, etc.).
I launch the activity, by "CarId" I open the desired object. The question is, how to properly filter the transmitted data so that only 2 out of 12 fields change?
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
GB
Hi,
Are you passing all values again in the service call or just the updated ones? if the later you can simply set a check to set the value in the object when the value received in the service is not blank.
Updated: 4 Mar 2021 0:05 EST
CPS foundation
RU
@Angel Hermira Thank you! I transfer only the updated fields. Please, tell me the best practice for filtering empty fields (pxIsBlank or length or what other function?).
Pegasystems Inc.
GB
@VitaliyL , I'd use @PropertyExists("propertyReference") && @PropertyHasValue(tools,"propertyReference") as a condition before setting the value. This will prevent from overwriting properties with value with properties that don't have value.
You need to be careful that your service properties are not initialised with blank values, in which case you'll need to check for those as well.
-
Vitaliy Lukashin
Updated: 5 Mar 2021 6:09 EST
CPS foundation
RU
You need to be careful that your service properties are not initialised with blank values, in which case you'll need to check for those as well.
Can you give advice on how best to make sure that the service does not initialize an empty property? in my incomplete, not experienced view, I see some a way using XML schema.
Is it possible to validate in more detail the values received by the service for correctness? Example: the vehicle release date must be in the past, or the email field must be in the format Proprietary information hidden. Using XML schema i can check for field type (string etc.)
Pegasystems Inc.
GB
@VitaliyL , I was referring to the message that you are receiving. In some cases space is consider a valid char that will depend on your requirements. If you think that the messages may contain space chars in the fields and these are not valid for your service you can trim the fields and then check if they have value.
Your condition would be something like this:
@PropertyExists(".PropertyName") && @trim(.PropertyName) != ""
-
Vitaliy Lukashin
Updated: 5 Mar 2021 6:10 EST
CPS foundation
RU
@Angel Hermira Thank you so much!
The last question is, do I understand correctly in order to more flexibly configure data validation at the service level (for example, the date is in the past or the format of the email or phone number, or only the values "aaaaa" or "bbbbb") , I must use Fault conditions?
Thanks again!
Pegasystems Inc.
GB
@VitaliyL , this depends on your requirements. Do you need to return the error to the service caller or the validations are part of your business processing?
If the first, you'll need to validate the input data and return the error message as the response. If the second you can apply the validation using validation rules and edit validate rules and record the errors as required.
-
Vitaliy Lukashin
Updated: 10 Mar 2021 7:39 EST
CPS foundation
RU
@Angel Hermira Greetings! I need service-level validation. Example - the email address is sent to the service in the wrong format. I want it to be checked at the service level, in case of an error, the data is not processed, but an error message is transmitted. I have a problem with understanding which tool to implement this.
I understand that, ideally, validation should happen from the client side of the request. But now I am learning and I want to understand how I can implement the correctness of the transmitted data regardless of the client. in the issue of validation, I miss the last piece to get a picture of understanding.
Pegasystems Inc.
GB
@VitaliyL , in a SOAP service you can validate with an XML Schema. You'll need to create a function that does this in Java and then send the error back in the response. This is helpful when you have large messages where you need to validate format across complex structures.
Another option is to use validate rules. You'll create the data structure in Platform to map the message. When the new message is received you map it to the data structure and validate the object using validate rules. If this fails you capture the error and send it back in the response to the service.
Both approaches have pros and cons. The first doesn't require the data structure to be created as per the WSDL but uses Java. The second is based on getting the data structure as defined in the WSDL. This is done automatically by the service wizard so perhaps the easiest to use.
-
Vitaliy Lukashin