[ 
https://issues.apache.org/jira/browse/AXIS2-4071?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12642476#action_12642476
 ] 

Antonio Andrade commented on AXIS2-4071:
----------------------------------------

Hi Amila, first of all, thank you for your comments.

I mentioned twice that the "fix" (quoted) didn't solve the duplication problem 
but it avoids side effects on external data structures (original schema 
documents) but I think I also implied (in another part) that the patch "fixes" 
the problem, sorry about that.

I'd be totally ok to throw an exception if a WSDL with those properties was 
difficult to find but I don't think that's the case (or what do you think?). I 
just run some internal tests and from 311 WSDL documents I'm testing with, 39 
lead to this duplication problem (12%). 

I would agree throwing an exception is there's a way to make it optional and 
delegate the responsibility of resolving any conflicts to the client. I can 
submit the patch and the JUnit Tests, no problem. What do you think?

So basically, after the schemas have been created, the 'populateService' method 
can call a protected method (i.e. validateXmlSchemas) which by default throws 
an exception when duplicated global elements declarations are found. Subclasses 
can then decide to overwrite the 'validateXmlSchemas' method and do something 
different (i.e. do not throw exception but resolve in a client-specific way the 
duplication of these elements). The already submitted patch would remain pretty 
much the same (wrapped elements would be created always into NEW XML schema 
documents) and the 'validateXmlSchemas' method would be added. What do you 
think?



> WSDL11ToAxisServiceBuilder + RPC/Literal OR HTTP binding =~ Inconsistent 
> XMLSchema object: duplicated global element declarations
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: AXIS2-4071
>                 URL: https://issues.apache.org/jira/browse/AXIS2-4071
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 1.4, nightly
>         Environment: Windows XP. 4GB RAM Intel Xeon dual-core @2.75Ghz
>            Reporter: Antonio Andrade
>         Attachments: AXIS2-4071.patch, JUnit Tests - Before.jpg
>
>   Original Estimate: 72h
>  Remaining Estimate: 72h
>
> In WSDL11ToAxisServiceBuilder:
>   1) Within the 'setup()' method, a map ('schemaMap') indexed by 
> targetNamespace and values equal root (W3C) Elements is populated
>   2) When either a RPC/Literal binding or an HTTP binding with message parts 
> referencing type definitions is found, new global element declarations based 
> on the WSDL operation name are created. These new elements can either be 
> added to an existing (W3C) Document (in case the 'schemMap'  contains a 
> document with the same target namespace as the one that the newly created 
> element has) or added to a newly created Document.:
>     a) If a new document is created, an additional namespace mapping 
> declaration is added to that document (see 'XMLNS_AXIS2WRAPPED' ). This helps 
> distinguishing this document among the other original ones.
>     b) If an additional document is NOT created, the new global element 
> declarations are added to an existing document. No additional namespace 
> mapping declaration is added.
>   3) After all wrapped elements have been created,  XmlSchema objects are 
> created from the original, modified and newly created W3C Documents
> Note that all this leads to duplicate global element declarations any time 
> there's already an element named after an operation name. This is very common 
> and happens every time operation names across multiple bindings are the same. 
>  In general, all this is caused by the creation of XML schema elements while 
> transforming operations using the RPC/Literal encoding style into the 
> Document/Literal encoding style using the wrapped convention.
> There is more than one problem associated with the creation of new XML global 
> element declarations:
>   1) First of all, the XML schema documents end up with duplicated global 
> element declarations which makes the Schema invalid. But why nobody seems to 
> have noticed it? I think it's just a coincidence, let me explain: A XmlSchema 
> object maintains a MAP, indexed by element name (QName) and XmlSchemaElement 
> objects as values. This map is used for a faster object retrieval. At the 
> same time, the XmlSchema object also maintains a LIST of all nodes 
> (XmlSchemaObject objects I think). So whenever duplicate elements are added 
> to the schema, the last-inserted elements overwrite the previous elements on 
> the MAP of elements but they are inserted with no problems in the LIST of 
> nodes and because the latter elements are usually what people is looking for 
> (i.e. in case of databinding libraries that create the client stub for a 
> single port), the 'correct' element is returned
>   2) If the Definition object (from WSDL4J) is used to populate multiple 
> AxisServices from different WSDL ports, for example, within the 
> 'WSDL11ToAllAxisServicesBuilder' (which, by the way doesn't seem to work at 
> all), the W3C Schema Document may end up with multiple duplicated global 
> element declarations and the 'AxisService.getSchemaElement(QName)' method 
> will fail to return the appropriate reference.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to