Question
Last activity: 2 Sep 2015 8:58 EDT
How to add xsi:nil=”true” to XML schema elements in SOAP request
The SOAP request that we are sending goes through DataPower, which is validating the int/decimal/long types (even though they are nillable with minOccurs=0). Is there any way to add xsi:nil="true" to XML schema elements with the options available in Pega 7.1.7.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
I just figured out this. In case if someone have to deal with DataPower, this answer might save some time. Per the PDN article (NodeID: 253396) I've mentioned in my previous msg, $is-present() API doesn't work for auto-generated XML. If we replace this in the generated JSP tag of XML Stream rule, Pega does include xsi:nil="true" attribute in the request envelope for the elements marked as 'nillable'.
Here are the detailed Steps:
1. Uncheck 'Auto-generated XML' under XML tab of XML Stream rule
2. Tweak the XML element as shown:
From: <pega:choose><pega:when test="$is-present(.MyProperty)"><MyProperty><pega:r n=".MyProperty" m="normal"/></MyProperty></pega:when><pega:otherwise><MyProperty xsi:nil="true"/></pega:otherwise></pega:choose>
To: <pega:choose><pega:when test="$is-present(.MyProperty)"><MyProperty><pega:r n=".MyProperty" m="normal"/></MyProperty></pega:when><pega:otherwise><MyProperty xsi:nil="true"/></pega:otherwise></pega:choose>
Hi Govardhan,
Is it Pega Service SOAP or Connect SOAP?
if SOAP service, are you for 'xsd:nil=true' in pega generated wsdl?
There is a 'Nillbale' option in XML Stream rule under 'node' tab.
Thanks Gopi for responding. This is ConnectSOAP. We are invoking a Java Web Service (WS), that goes through Data Power (DP) (since the WebService proxy is configured in DP). DP is validating integer/decimal/long types not to have null values even though they have nillable="true" defined in the generated XSD of Java Web Service. One possible way to get rid off this situation as per the IBM article http://dw.developer-works.com/article/10225679/INT+Validation+%23+XI50 is to specify xsi:nil="true" on all elements of type int, long, decimal, datetime...instead of empty node.
After we consume the WS, in the auto-generated XML Stream rule, is there any way we can have Pega add xsi:nil="true" in Pega 7.1.7.
There is already a PDN article (https://community.pega.com/support/support-articles/empty-nodes-request-xml-even-though-optional-checked-0) that talks about an issue in Pega 7.1.7 where the optional attributes have empty node created instead of no node.
Question: In the XML stream rule of PRPC, even though the element setting have 'nillable' checkbox checked, the request XML doesn't include xsi:nil="true".
Thanks again.
Accepted Solution
I just figured out this. In case if someone have to deal with DataPower, this answer might save some time. Per the PDN article (NodeID: 253396) I've mentioned in my previous msg, $is-present() API doesn't work for auto-generated XML. If we replace this in the generated JSP tag of XML Stream rule, Pega does include xsi:nil="true" attribute in the request envelope for the elements marked as 'nillable'.
Here are the detailed Steps:
1. Uncheck 'Auto-generated XML' under XML tab of XML Stream rule
2. Tweak the XML element as shown:
From: <pega:choose><pega:when test="$is-present(.MyProperty)"><MyProperty><pega:r n=".MyProperty" m="normal"/></MyProperty></pega:when><pega:otherwise><MyProperty xsi:nil="true"/></pega:otherwise></pega:choose>
To: <pega:choose><pega:when test="$is-present(.MyProperty)"><MyProperty><pega:r n=".MyProperty" m="normal"/></MyProperty></pega:when><pega:otherwise><MyProperty xsi:nil="true"/></pega:otherwise></pega:choose>
PEG
IN
Hi Govardan,
I could see to and From are same. You mean to say like below
From: <pega:choose><pega:when test="$is-present(.MyProperty)">< MyProperty ><pega:r n=". MyProperty " m="normal"/></ MyProperty ></pega:when><pega:otherwise>< MyProperty /></pega:otherwise></pega:choose>
To: <pega:choose><pega:when test="$is-present(. MyProperty )">< MyProperty ><pega:r n=". MyProperty " m="normal"/></ MyProperty ></pega:when><pega:otherwise>< MyProperty xsi:nil="true"/></pega:otherwise></pega:choose >
Oops! My edits in notepad were wrong and I pasted them as-is. Thanks GG
Here is the correct To:
To: <pega:choose><pega:when test=".MyProperty!='' "><MyProperty><pega:r n=".MyProperty" m="normal"/></MyProperty></pega:when><pega:otherwise><MyProperty xsi:nil="true"/></pega:otherwise></pega:choose>