[ 
https://issues.apache.org/jira/browse/CXF-2855?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nitro updated CXF-2855:
-----------------------

    Description: 
Configuration of a private customization implemented with XJC plugin 
architecture is not copied into customized WSDL. For instance:

WSDL:

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions       targetNamespace="http://some.ns.com/";
                                        
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
                                        
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
                                        
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
                                        
xmlns="http://schemas.xmlsoap.org/wsdl/";>

        <types>
                <xsd:schema     targetNamespace="http://some.ns.com/message";
                                        
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
                                        
xmlns="http://www.w3.org/2001/XMLSchema";>

                        <element name="myMessage">
                                <complexType>
                                        <sequence>
                                                <element name="number" 
type="int"/>
                                        </sequence>
                                </complexType>
                        </element>
                </xsd:schema>
        </types>
        
        <!-- Parts / ports definitions -->
        
</wsdl:definitions>


JAX-WS customization:

<?xml version="1.0" encoding="UTF-8"?>

<jaxws:bindings wsdlLocation="my.wsdl"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
        xmlns:xsd="http://www.w3.org/2001/XMLSchema";
        xmlns:jaxws="http://java.sun.com/xml/ns/jaxws";
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb";
        xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc";
        xmlns:my-xjc="http://some.ns.com/xjc";
        jaxb:version="2.0" jaxb:extensionBindingPrefixes="xjc my-xjc">

        <jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema">
                <jaxb:bindings 
node="xsd:eleme...@name='myMessage']//xsd:eleme...@name='numbers']">
                        <my-xjc:somecfg a_param="a value"/>
                </jaxb:bindings>
        </jaxws:bindings>
</jaxws:bindings>


The problem is that the <my-xjc:somecfg/> element is not copied into the 
<annotation> of the respective element.

Also the jaxb:extensionBindingPrefixes="" attribute is copied at the wrong 
place (on the myMessage element) additionally to the <xsd:schema/> element.

Finally the WSDL2Java tool doesn't respect the proper format parsing the 
jaxb:extensionBindingPrefixes="" attribute (using comma-separated values 
instead of the whitespace separated list).

I wrote a simple fix to these problems listed above but it could be improved to 
actually check better the validity of the xml elements.


  was:
Configuration of a private customization implemented with XJC plugin 
architecture is not copied into customized WSDL. For instance:

WSDL:

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions       targetNamespace="http://some.ns.com/";
                                        
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
                                        
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
                                        
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
                                        
xmlns="http://schemas.xmlsoap.org/wsdl/";>

        <types>
                <xsd:schema     targetNamespace="http://some.ns.com/message";
                                        
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
                                        
xmlns="http://www.w3.org/2001/XMLSchema";>

                        <element name="myMessage">
                                <complexType>
                                        <sequence>
                                                <element name="number" 
type="int"/>
                                        </sequence>
                                </complexType>
                        </element>
                </xsd:schema>
        </types>
        
        <!-- Parts / ports definitions -->
        
</wsdl:definitions>


JAX-WS customization:

<?xml version="1.0" encoding="UTF-8"?>

<jaxws:bindings wsdlLocation="my.wsdl"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
        xmlns:xsd="http://www.w3.org/2001/XMLSchema";
        xmlns:jaxws="http://java.sun.com/xml/ns/jaxws";
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb";
        xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc";
        xmlns:my-xjc="http://some.ns.com/xjc";
        jaxb:version="2.0" jaxb:extensionBindingPrefixes="xjc my-xjc">

        <jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema">
                <jaxb:bindings 
node="xsd:eleme...@name='myMessage']//xsd:eleme...@name='numbers']">
                        <my-xjc:somecfg a_param="a value"/>
                </jaxb:bindings>
        </jaxws:bindings>
</jaxws:bindings>


The problem is that the <my-xjc:somecfg/> element is not copied into the 
<annotation> of the respective element.

Also the jaxb:extensionBindingPrefixes="" attribute is copied at the wrong 
place (on the myMessage element) additionally to the <xsd:schema/> element.

Finally the WSDL2Java tool doesn't respect the proper format parsing the 
jaxb:extensionBindingPrefixes="" attribute (using comma-separated values 
instead of the whitespace separated list).

I wrote a simple fix to these problems listed above but it could be improved to 
actually check better the validity of the xml elements:



Index: 
tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
===================================================================
--- 
tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
 (revision 955974)
+++ 
tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
 (working copy)
@@ -238,7 +238,9 @@
     }
 
     protected void copyAllJaxbDeclarations(final Node schemaNode, final 
Element jaxwsBindingNode) {
-        appendJaxbVersion((Element)schemaNode);
+       if (isSchemaElement((Element)schemaNode)) {
+               appendJaxbVersion((Element)schemaNode);
+       }
 
         Node[] embededNodes = getAnnotationNodes(schemaNode);
         Node annotationNode = embededNodes[0];
@@ -247,15 +249,18 @@
         for (Node childNode = jaxwsBindingNode.getFirstChild();
             childNode != null;
             childNode = childNode.getNextSibling()) {
-            
-            copyJaxbAttributes(childNode, (Element)schemaNode);
-            
-            if (!isJaxbBindings(childNode)) {
+
+               if (isSchemaElement((Element)schemaNode)) {
+                       copyJaxbAttributes(childNode, (Element)schemaNode);
+               }
+
+               // TODO: check for valid extension namespaces
+            if (!(childNode instanceof Element)) { 
//!isJaxbBindings(childNode)) {
                 continue;
             }
             
             Element childEl = (Element)childNode;
-            if (isJaxbBindingsElement(childEl)) {
+            if (isJaxbBindings(childNode) && isJaxbBindingsElement(childEl)) {
                 
                 NodeList nlist = nodeSelector.queryNodes(schemaNode, 
childEl.getAttribute("node"));
                 for (int i = 0; i < nlist.getLength(); i++) {
@@ -307,7 +312,7 @@
                         String pfxs = attr.getValue();
                         while (pfxs.length() > 0) {
                             String pfx = pfxs;
-                            int idx = pfx.indexOf(',');
+                            int idx = pfx.indexOf(' ');
                             if (idx != -1) {
                                 pfxs = pfxs.substring(idx + 1);
                                 pfx = pfx.substring(0, idx);
@@ -598,6 +603,11 @@
         return this.wsdlNode;
     }
 
+    private boolean isSchemaElement(Node schema) {
+        return ToolConstants.SCHEMA_URI.equals(schema.getNamespaceURI())
+               && "schema".equals(schema.getLocalName());
+    }
+
     private boolean isJAXWSBindings(Node bindings) {
         return 
ToolConstants.NS_JAXWS_BINDINGS.equals(bindings.getNamespaceURI())
                && "bindings".equals(bindings.getLocalName());





> WSDL2Java JAX-WS XJC customizations
> -----------------------------------
>
>                 Key: CXF-2855
>                 URL: https://issues.apache.org/jira/browse/CXF-2855
>             Project: CXF
>          Issue Type: Improvement
>          Components: Tooling
>    Affects Versions: 2.2.9
>            Reporter: Nitro
>         Attachments: apache-cxf-2.2.9-wsdlto-xjc-fix.diff
>
>
> Configuration of a private customization implemented with XJC plugin 
> architecture is not copied into customized WSDL. For instance:
> WSDL:
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions     targetNamespace="http://some.ns.com/";
>                                       
> xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>                                       
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
>                                       
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
>                                       
> xmlns="http://schemas.xmlsoap.org/wsdl/";>
>       <types>
>               <xsd:schema     targetNamespace="http://some.ns.com/message";
>                                       
> xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>                                       
> xmlns="http://www.w3.org/2001/XMLSchema";>
>                       <element name="myMessage">
>                               <complexType>
>                                       <sequence>
>                                               <element name="number" 
> type="int"/>
>                                       </sequence>
>                               </complexType>
>                       </element>
>               </xsd:schema>
>       </types>
>       
>       <!-- Parts / ports definitions -->
>       
> </wsdl:definitions>
> JAX-WS customization:
> <?xml version="1.0" encoding="UTF-8"?>
> <jaxws:bindings wsdlLocation="my.wsdl"
>       xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
>       xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>       xmlns:jaxws="http://java.sun.com/xml/ns/jaxws";
>       xmlns:jaxb="http://java.sun.com/xml/ns/jaxb";
>       xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc";
>       xmlns:my-xjc="http://some.ns.com/xjc";
>       jaxb:version="2.0" jaxb:extensionBindingPrefixes="xjc my-xjc">
>       <jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema">
>               <jaxb:bindings 
> node="xsd:eleme...@name='myMessage']//xsd:eleme...@name='numbers']">
>                       <my-xjc:somecfg a_param="a value"/>
>               </jaxb:bindings>
>       </jaxws:bindings>
> </jaxws:bindings>
> The problem is that the <my-xjc:somecfg/> element is not copied into the 
> <annotation> of the respective element.
> Also the jaxb:extensionBindingPrefixes="" attribute is copied at the wrong 
> place (on the myMessage element) additionally to the <xsd:schema/> element.
> Finally the WSDL2Java tool doesn't respect the proper format parsing the 
> jaxb:extensionBindingPrefixes="" attribute (using comma-separated values 
> instead of the whitespace separated list).
> I wrote a simple fix to these problems listed above but it could be improved 
> to actually check better the validity of the xml elements.

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

Reply via email to