Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Schema validation in Parse rule does not validate decimal field

SA-3904

Summary



The restrictions "fractionDigits" and "totalDigits" on a decimal type element are not checked when a schema validation is set on a parse rule.

In the schema I defined a type "bedragType" as decimal with the restrictions "fractionDigits" as 2 and "totalDigits" as 11 and when I sens a value '1234567890.12' or '123456789.123' in an elemant of this type, Pega excepts this value and does not return an error.

When validating this in SoapUI it does give me the expected error.

Reference to description of the restriction elements in the xsd: http://www.w3.org/TR/xmlschema-2/#rf-totalDigits

Error Messages



No error is returned but one was expected.

Steps to Reproduce



1) Build a service with a WSDL and XSD that includes an element as decimal with the restrictions "fractionDigits" as 2 and "totalDigits" as 11.

2) Ensure schemavalidation is done on the request.
3) Call the service with the values '1234567890.12' and '123456789.123' for the decimal element.

Root Cause



The root cause of this problem is a defect in customer application code/rules. The validation of decimal from xsd is working as expected. Using page messages does not stop the soap processing, however using this page message we could implement a soap fault to return back to client.


Resolution



The issue is resolved by the following explaination / demonstration.

The “On Error” option is set to “Add Page Message” in the parse XML instance as shown in the example below.


 
The On Error -> “Add Page Message” behaviour does add the page message in the issue scenario but will continue processing. We checked this by checking the page messages and printing them on the first step of the service activity.
 
2014-11-25 16:21:19,780 [http-apr-8092-exec-6] [  STANDARD] [C62SP2ML1FW:01.01.01] (2SP2ML1FW_Data_Customer.Action) INFO  lvargmw7eu-2|10.4.28.174|SOAP|FringeFWPRPC62SP2ML1FWDataCustomer|Services|getCustomerFromID|A54D3D1C7EF6853B3C76A5952DD224D76  - ** Error Found: cvc-fractionDigits-valid: Value '123.2223' has 4 fraction digits, but the number of fraction digits has been limited to 2.
** Error Found: cvc-type.3.1.3: The value '123.2223' of element 'exam:Salary' is not valid.
 
Because the page messages are available on the activity you can perform required action for this scenario and report the fault. Here is one example.
  1. Service Activity to Set the messages to a FaultString property


 2. Setting fault conditions on the service rule by using a when rule (that checks the page messages),


 
In the test scenario the following SOAP Fault is created:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <soap:Fault>
         <soap:Code>
            <soap:Value>soap:Receiver</soap:Value>
         </soap:Code>
         <soap:Reason>
            <soap:Text xml:lang="en-US">** Error Found: cvc-fractionDigits-valid: Value '123.2223' has 4 fraction digits, but the number of fraction digits has been limited to 2.
** Error Found: cvc-type.3.1.3: The value '123.2223' of element 'exam:Salary' is not valid.</soap:Text>
         </soap:Reason>
         <soap:Detail>
            <FaultResponse>** Error Found: cvc-fractionDigits-valid: Value '123.2223' has 4 fraction digits, but the number of fraction digits has been limited to 2.
** Error Found: cvc-type.3.1.3: The value '123.2223' of element 'exam:Salary' is not valid.</FaultResponse>
         </soap:Detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>
 
 

Published January 31, 2016 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us