[ https://issues.apache.org/jira/browse/CXF-6163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14253430#comment-14253430 ]
ASF GitHub Bot commented on CXF-6163: ------------------------------------- GitHub user DemonShi opened a pull request: https://github.com/apache/cxf/pull/46 [CXF-6163] Fixed xsd:any behaviour when used with minOccurs=0, maxOccurs>1 * xsd:any deserializer does not go into infinite loop when xsd:any cannot match any element and minOccurs=0 Here is how generated code now looks like: ```javascript var anyObject = []; var matcher = new org_apache_cxf_any_ns_matcher(org_apache_cxf_any_ns_matcher.ANY, 'urn:...', [], null); var anyNeeded = 0; var anyAllowed = 9223372036854775807; while (anyNeeded > 0 || anyAllowed > 0) { var anyURI; var anyLocalPart; var anyMatched = false; if (curElement) { anyURI = cxfjsutils.getElementNamespaceURI(curElement); anyLocalPart = cxfjsutils.getNodeLocalName(curElement); var anyQName = '{' + anyURI + '}' + anyLocalPart; cxfjsutils.trace('any match: ' + anyQName); anyMatched = matcher.match(anyURI, anyLocalPart) cxfjsutils.trace(' --> ' + anyMatched); } if (anyMatched) { anyDeserializer = cxfjsutils.interfaceObject.globalElementDeserializers[anyQName]; cxfjsutils.trace(' deserializer: ' + anyDeserializer); if (anyDeserializer) { var anyValue = anyDeserializer(cxfjsutils, curElement); } else { var anyValue = curElement.nodeValue; } anyObject.push(anyValue); anyNeeded--; anyAllowed--; curElement = cxfjsutils.getNextElementSibling(curElement); } else { if (anyNeeded > 0) { throw 'not enough ws:any elements'; } else { break; } } } var anyHolder = new org_apache_cxf_any_holder(anyURI, anyLocalPart, anyValue); newobject.setAny(anyHolder); ``` * xsd:any serializer does not throw an exception when xsd:any element is being passed as empty array and minOccurs=0 You can merge this pull request into a Git repository by running: $ git pull https://github.com/DemonShi/cxf cxf-6163 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cxf/pull/46.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #46 ---- commit 5824a9e56386b1938667d41d27c1007943fcf098 Author: Andrii Nikitiuk <demonshi...@gmail.com> Date: 2014-12-19T14:17:27Z [CXF-6163] Fixed xsd:any behaviour when used with minOccurs=0, maxOccurs>1 ---- > WSDL Javascript generator for xsd:any elements is not correct when any is > optional > ---------------------------------------------------------------------------------- > > Key: CXF-6163 > URL: https://issues.apache.org/jira/browse/CXF-6163 > Project: CXF > Issue Type: Bug > Components: JavaScript Client > Affects Versions: 3.0.2 > Reporter: Andrii Nikitiuk > Priority: Minor > Labels: javascript, optional, wsdl2js, xsd, xsd:any > > Here is an example of WSDL complexType with any element: > {code} > <complexType name="SomeType"> > <sequence> > <element name="arg1" type="xsd:int"/> > <any maxOccurs="unbounded" minOccurs="0"/> > </sequence> > </complexType> > {code} > Here are some problems: > * In generated Javascript this xsd:any element is marked as "required", while > we have minOccurs="0" > * Deserializer of this xsd:any element goes into infinite loop when there is > nothing that can be threaten as xsd:any > * Serializer also thinks of this xsd:any as required element and throws > exception if it is null > Expected behavior: > * xsd:any should be threaten as optional element > * parsing of XML with xsd:any element in WSDL should not hang -- This message was sent by Atlassian JIRA (v6.3.4#6332)