You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Michael Klimiuk (JIRA)" <ji...@apache.org> on 2009/10/13 15:00:33 UTC

[jira] Created: (CXF-2468) attribute namespace is missed in out message in case of XmlBeans data binding

attribute namespace is missed in out message in  case of XmlBeans data binding
------------------------------------------------------------------------------

                 Key: CXF-2468
                 URL: https://issues.apache.org/jira/browse/CXF-2468
             Project: CXF
          Issue Type: Bug
          Components: OtherDatabindings
            Reporter: Michael Klimiuk
            Priority: Blocker


SCENARIO:

The XmlBeans databinding is used.

Trying to send a message with an input data like:

<myOperation
        xmlns="http://sandbox.org/services/MyService/myOperation"
        xmlns:s1="http://sandbox.org/datatypes/one"
        xmlns:s2="http://sandbox.org/datatypes/two"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <data>
        <s1:oneElement>
            <s2:twoElement xsi:nil="true"/>
        </s1:oneElement>
    </data>
</myOperation>


ACTUAL RESULT:

The out message is generated as follows:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
        <data>
            <oneElement xmlns="http://sandbox.org/datatypes/one">
                <twoElement xmlns="http://sandbox.org/datatypes/two" xsi:nil="true"/>
            </oneElement>
        </data>
    </myOperation>
</soap:Body>
</soap:Envelope>

Namespace definition for "xsi" prefix is missed. And the receiver fails to process the message because of validation.


EXPECTED RESULT:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
        <data>
            <oneElement xmlns="http://sandbox.org/datatypes/one">
                <twoElement xmlns="http://sandbox.org/datatypes/two" 
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                            xsi:nil="true"/>
            </oneElement>
        </data>
    </myOperation>
</soap:Body>
</soap:Envelope>

I.e. the namespace for "xsi" prefix is present.


ANALYSIS:

Analysis is based on the CXF 2.2.3.

Please have a look at the sources:

   Class: org.apache.cxf.staxutils.StaxUtils
   Method: writeStartElement(XMLStreamReader reader, XMLStreamWriter writer)
   The code under his comment -> // Write out attributes

My guess is:

   If we have both "ns" and "nsPrefix" that are not empty then the namespace definition should be written.

   506            } else {
   507                writer.writeNamespace(nsPrefix, ns); // <-- THIS IS A NEW EXAMPLE LINE OF WHAT IS DESIRED
   508                writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader
   509                    .getAttributeLocalName(i), reader.getAttributeValue(i));
   510            }


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


[jira] Commented: (CXF-2468) attribute namespace is missed in out message in case of XmlBeans data binding

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12765148#action_12765148 ] 

Daniel Kulp commented on CXF-2468:
----------------------------------



Is there any way you could create a small testcase and attach?  This actually looks like a bug in xmlbeans.   We pretty much copy the events that xmlbeans gives us to the output.   If it's not providing the xsi namespace when it needs it, that's possibly a bug in xmlbeans.   However, we may be able to provide a better workaround if I can get a good testcase that would allow me to dig in better.     Maybe call the XmlOptions.setSaveNamespacesFirst() option or something to put them at the top level.   Hard to tell without a testcase.


> attribute namespace is missed in out message in  case of XmlBeans data binding
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2468
>                 URL: https://issues.apache.org/jira/browse/CXF-2468
>             Project: CXF
>          Issue Type: Bug
>          Components: OtherDatabindings
>            Reporter: Michael Klimiuk
>            Priority: Blocker
>
> SCENARIO:
> The XmlBeans databinding is used.
> Trying to send a message with an input data like:
> <myOperation
>         xmlns="http://sandbox.org/services/MyService/myOperation"
>         xmlns:s1="http://sandbox.org/datatypes/one"
>         xmlns:s2="http://sandbox.org/datatypes/two"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>     <data>
>         <s1:oneElement>
>             <s2:twoElement xsi:nil="true"/>
>         </s1:oneElement>
>     </data>
> </myOperation>
> ACTUAL RESULT:
> The out message is generated as follows:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> Namespace definition for "xsi" prefix is missed. And the receiver fails to process the message because of validation.
> EXPECTED RESULT:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" 
>                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>                             xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> I.e. the namespace for "xsi" prefix is present.
> ANALYSIS:
> Analysis is based on the CXF 2.2.3.
> Please have a look at the sources:
>    Class: org.apache.cxf.staxutils.StaxUtils
>    Method: writeStartElement(XMLStreamReader reader, XMLStreamWriter writer)
>    The code under his comment -> // Write out attributes
> My guess is:
>    If we have both "ns" and "nsPrefix" that are not empty then the namespace definition should be written.
>    506            } else {
>    507                writer.writeNamespace(nsPrefix, ns); // <-- THIS IS A NEW EXAMPLE LINE OF WHAT IS DESIRED
>    508                writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader
>    509                    .getAttributeLocalName(i), reader.getAttributeValue(i));
>    510            }

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


[jira] Commented: (CXF-2468) attribute namespace is missed in out message in case of XmlBeans data binding

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12765657#action_12765657 ] 

Daniel Kulp commented on CXF-2468:
----------------------------------


Thanks for the test case.   It's definitely an xmlbeans bug as the XMLStreamReader they provide never defines a namespace for xsi.   I've updated the StaxUtils to do some checking of the namespaces/prefixes to catch this now.   We already do this for the element qnames to catch broken prefixes and stuff on the element level.  I just updated it to also catch them for attributes.  Running tests now.

> attribute namespace is missed in out message in  case of XmlBeans data binding
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2468
>                 URL: https://issues.apache.org/jira/browse/CXF-2468
>             Project: CXF
>          Issue Type: Bug
>          Components: OtherDatabindings
>            Reporter: Michael Klimiuk
>            Priority: Blocker
>         Attachments: CXF2468.zip
>
>
> SCENARIO:
> The XmlBeans databinding is used.
> Trying to send a message with an input data like:
> <myOperation
>         xmlns="http://sandbox.org/services/MyService/myOperation"
>         xmlns:s1="http://sandbox.org/datatypes/one"
>         xmlns:s2="http://sandbox.org/datatypes/two"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>     <data>
>         <s1:oneElement>
>             <s2:twoElement xsi:nil="true"/>
>         </s1:oneElement>
>     </data>
> </myOperation>
> ACTUAL RESULT:
> The out message is generated as follows:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> Namespace definition for "xsi" prefix is missed. And the receiver fails to process the message because of validation.
> EXPECTED RESULT:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" 
>                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>                             xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> I.e. the namespace for "xsi" prefix is present.
> ANALYSIS:
> Analysis is based on the CXF 2.2.3.
> Please have a look at the sources:
>    Class: org.apache.cxf.staxutils.StaxUtils
>    Method: writeStartElement(XMLStreamReader reader, XMLStreamWriter writer)
>    The code under his comment -> // Write out attributes
> My guess is:
>    If we have both "ns" and "nsPrefix" that are not empty then the namespace definition should be written.
>    506            } else {
>    507                writer.writeNamespace(nsPrefix, ns); // <-- THIS IS A NEW EXAMPLE LINE OF WHAT IS DESIRED
>    508                writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader
>    509                    .getAttributeLocalName(i), reader.getAttributeValue(i));
>    510            }

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


[jira] Commented: (CXF-2468) attribute namespace is missed in out message in case of XmlBeans data binding

Posted by "Michael Klimiuk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2468?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12765409#action_12765409 ] 

Michael Klimiuk commented on CXF-2468:
--------------------------------------

Thanks for a quick response, Daniel. Will try to provide the testcase today.

> attribute namespace is missed in out message in  case of XmlBeans data binding
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2468
>                 URL: https://issues.apache.org/jira/browse/CXF-2468
>             Project: CXF
>          Issue Type: Bug
>          Components: OtherDatabindings
>            Reporter: Michael Klimiuk
>            Priority: Blocker
>
> SCENARIO:
> The XmlBeans databinding is used.
> Trying to send a message with an input data like:
> <myOperation
>         xmlns="http://sandbox.org/services/MyService/myOperation"
>         xmlns:s1="http://sandbox.org/datatypes/one"
>         xmlns:s2="http://sandbox.org/datatypes/two"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>     <data>
>         <s1:oneElement>
>             <s2:twoElement xsi:nil="true"/>
>         </s1:oneElement>
>     </data>
> </myOperation>
> ACTUAL RESULT:
> The out message is generated as follows:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> Namespace definition for "xsi" prefix is missed. And the receiver fails to process the message because of validation.
> EXPECTED RESULT:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" 
>                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>                             xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> I.e. the namespace for "xsi" prefix is present.
> ANALYSIS:
> Analysis is based on the CXF 2.2.3.
> Please have a look at the sources:
>    Class: org.apache.cxf.staxutils.StaxUtils
>    Method: writeStartElement(XMLStreamReader reader, XMLStreamWriter writer)
>    The code under his comment -> // Write out attributes
> My guess is:
>    If we have both "ns" and "nsPrefix" that are not empty then the namespace definition should be written.
>    506            } else {
>    507                writer.writeNamespace(nsPrefix, ns); // <-- THIS IS A NEW EXAMPLE LINE OF WHAT IS DESIRED
>    508                writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader
>    509                    .getAttributeLocalName(i), reader.getAttributeValue(i));
>    510            }

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


[jira] Resolved: (CXF-2468) attribute namespace is missed in out message in case of XmlBeans data binding

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-2468?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp resolved CXF-2468.
------------------------------

    Resolution: Fixed

> As stated above the xml reader does not provide the namespace for xsi, but the same test (that attached) shows that it does provide it. 

The XMLStreamReader does not, but the toString method that is used when doing println(doc) does.    As mentioned, bug in XMLBeans XMLStreamReader thing.



> writer.writeNamespace(nsPrefix, ns); // <-- FIX: NEW LINE ADDED 

You don't want to do that as ALL attributes that are namespace prefixed would end up with new namespace declarations outputted.   The fix I implemented checks if the namespace is already declared properly and on writes out the namespace decl if it really need to.

See:
http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?p2=/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java&p1=/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java&r1=825221&r2=825220&view=diff&pathrev=825221


> attribute namespace is missed in out message in  case of XmlBeans data binding
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2468
>                 URL: https://issues.apache.org/jira/browse/CXF-2468
>             Project: CXF
>          Issue Type: Bug
>          Components: OtherDatabindings
>            Reporter: Michael Klimiuk
>            Assignee: Daniel Kulp
>            Priority: Blocker
>             Fix For: 2.1.8, 2.2.5
>
>         Attachments: CXF2468.zip
>
>
> SCENARIO:
> The XmlBeans databinding is used.
> Trying to send a message with an input data like:
> <myOperation
>         xmlns="http://sandbox.org/services/MyService/myOperation"
>         xmlns:s1="http://sandbox.org/datatypes/one"
>         xmlns:s2="http://sandbox.org/datatypes/two"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>     <data>
>         <s1:oneElement>
>             <s2:twoElement xsi:nil="true"/>
>         </s1:oneElement>
>     </data>
> </myOperation>
> ACTUAL RESULT:
> The out message is generated as follows:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> Namespace definition for "xsi" prefix is missed. And the receiver fails to process the message because of validation.
> EXPECTED RESULT:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" 
>                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>                             xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> I.e. the namespace for "xsi" prefix is present.
> ANALYSIS:
> Analysis is based on the CXF 2.2.3.
> Please have a look at the sources:
>    Class: org.apache.cxf.staxutils.StaxUtils
>    Method: writeStartElement(XMLStreamReader reader, XMLStreamWriter writer)
>    The code under his comment -> // Write out attributes
> My guess is:
>    If we have both "ns" and "nsPrefix" that are not empty then the namespace definition should be written.
>    506            } else {
>    507                writer.writeNamespace(nsPrefix, ns); // <-- THIS IS A NEW EXAMPLE LINE OF WHAT IS DESIRED
>    508                writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader
>    509                    .getAttributeLocalName(i), reader.getAttributeValue(i));
>    510            }

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


[jira] Updated: (CXF-2468) attribute namespace is missed in out message in case of XmlBeans data binding

Posted by "Michael Klimiuk (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-2468?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Klimiuk updated CXF-2468:
---------------------------------

    Attachment: CXF2468.zip

Please the test project attached.

README.txt

1. Make sure "cxf.dir" property in "build.properties" file points
   to the CXF-2.2.3 directory with libs.

2. Run ant.

3. The error will occur but in the logs we can see the outgoing message:

   <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
     <soap:Body>
       <myOperationRequest xmlns="http://sandbox.org/services/myService/myDataTypes">
         <info>
           <firstName>Mike</firstName>
           <lastName xsi:nil="true" />
         </info>
       </myOperationRequest>
     </soap:Body>
   </soap:Envelope>

   I.e. no defnition for "xsi" prefix.



> attribute namespace is missed in out message in  case of XmlBeans data binding
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2468
>                 URL: https://issues.apache.org/jira/browse/CXF-2468
>             Project: CXF
>          Issue Type: Bug
>          Components: OtherDatabindings
>            Reporter: Michael Klimiuk
>            Priority: Blocker
>         Attachments: CXF2468.zip
>
>
> SCENARIO:
> The XmlBeans databinding is used.
> Trying to send a message with an input data like:
> <myOperation
>         xmlns="http://sandbox.org/services/MyService/myOperation"
>         xmlns:s1="http://sandbox.org/datatypes/one"
>         xmlns:s2="http://sandbox.org/datatypes/two"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>     <data>
>         <s1:oneElement>
>             <s2:twoElement xsi:nil="true"/>
>         </s1:oneElement>
>     </data>
> </myOperation>
> ACTUAL RESULT:
> The out message is generated as follows:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> Namespace definition for "xsi" prefix is missed. And the receiver fails to process the message because of validation.
> EXPECTED RESULT:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" 
>                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>                             xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> I.e. the namespace for "xsi" prefix is present.
> ANALYSIS:
> Analysis is based on the CXF 2.2.3.
> Please have a look at the sources:
>    Class: org.apache.cxf.staxutils.StaxUtils
>    Method: writeStartElement(XMLStreamReader reader, XMLStreamWriter writer)
>    The code under his comment -> // Write out attributes
> My guess is:
>    If we have both "ns" and "nsPrefix" that are not empty then the namespace definition should be written.
>    506            } else {
>    507                writer.writeNamespace(nsPrefix, ns); // <-- THIS IS A NEW EXAMPLE LINE OF WHAT IS DESIRED
>    508                writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader
>    509                    .getAttributeLocalName(i), reader.getAttributeValue(i));
>    510            }

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


[jira] Resolved: (CXF-2468) attribute namespace is missed in out message in case of XmlBeans data binding

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-2468?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp resolved CXF-2468.
------------------------------

       Resolution: Fixed
    Fix Version/s: 2.2.5
                   2.1.8
         Assignee: Daniel Kulp

> attribute namespace is missed in out message in  case of XmlBeans data binding
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2468
>                 URL: https://issues.apache.org/jira/browse/CXF-2468
>             Project: CXF
>          Issue Type: Bug
>          Components: OtherDatabindings
>            Reporter: Michael Klimiuk
>            Assignee: Daniel Kulp
>            Priority: Blocker
>             Fix For: 2.1.8, 2.2.5
>
>         Attachments: CXF2468.zip
>
>
> SCENARIO:
> The XmlBeans databinding is used.
> Trying to send a message with an input data like:
> <myOperation
>         xmlns="http://sandbox.org/services/MyService/myOperation"
>         xmlns:s1="http://sandbox.org/datatypes/one"
>         xmlns:s2="http://sandbox.org/datatypes/two"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>     <data>
>         <s1:oneElement>
>             <s2:twoElement xsi:nil="true"/>
>         </s1:oneElement>
>     </data>
> </myOperation>
> ACTUAL RESULT:
> The out message is generated as follows:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> Namespace definition for "xsi" prefix is missed. And the receiver fails to process the message because of validation.
> EXPECTED RESULT:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" 
>                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>                             xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> I.e. the namespace for "xsi" prefix is present.
> ANALYSIS:
> Analysis is based on the CXF 2.2.3.
> Please have a look at the sources:
>    Class: org.apache.cxf.staxutils.StaxUtils
>    Method: writeStartElement(XMLStreamReader reader, XMLStreamWriter writer)
>    The code under his comment -> // Write out attributes
> My guess is:
>    If we have both "ns" and "nsPrefix" that are not empty then the namespace definition should be written.
>    506            } else {
>    507                writer.writeNamespace(nsPrefix, ns); // <-- THIS IS A NEW EXAMPLE LINE OF WHAT IS DESIRED
>    508                writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader
>    509                    .getAttributeLocalName(i), reader.getAttributeValue(i));
>    510            }

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


[jira] Reopened: (CXF-2468) attribute namespace is missed in out message in case of XmlBeans data binding

Posted by "Michael Klimiuk (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-2468?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Klimiuk reopened CXF-2468:
----------------------------------


Hi Daniel, I've reopened the issue just to make sure that the situation is clear.

As stated above the xml reader does not provide the namespace for xsi, but the same test (that attached) shows that it does provide it.

We can see it if we include the output of the xml bean object in the test before the service invocation, like:

    System.out.println("Document = " + doc);

this will show us:

    Document = <myOperationRequest xmlns="http://sandbox.org/services/myService/myDataTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><info><firstName>Mike</firstName><lastName xsi:nil="true"/></info></myOperationRequest>

In the output message this information is missed, but if we do the following fix in the StaxUtils class(as I mentioned earlier):

>    506            } else {
>    507                writer.writeNamespace(nsPrefix, ns); // <-- FIX: NEW LINE ADDED
>    508                writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader
>    509                    .getAttributeLocalName(i), reader.getAttributeValue(i));
>    510            }

Than the namespace for xsi will be caught and used.

This fix works in our project, so please review it and tell whether this is the right way or not.

> attribute namespace is missed in out message in  case of XmlBeans data binding
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2468
>                 URL: https://issues.apache.org/jira/browse/CXF-2468
>             Project: CXF
>          Issue Type: Bug
>          Components: OtherDatabindings
>            Reporter: Michael Klimiuk
>            Assignee: Daniel Kulp
>            Priority: Blocker
>             Fix For: 2.1.8, 2.2.5
>
>         Attachments: CXF2468.zip
>
>
> SCENARIO:
> The XmlBeans databinding is used.
> Trying to send a message with an input data like:
> <myOperation
>         xmlns="http://sandbox.org/services/MyService/myOperation"
>         xmlns:s1="http://sandbox.org/datatypes/one"
>         xmlns:s2="http://sandbox.org/datatypes/two"
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>     <data>
>         <s1:oneElement>
>             <s2:twoElement xsi:nil="true"/>
>         </s1:oneElement>
>     </data>
> </myOperation>
> ACTUAL RESULT:
> The out message is generated as follows:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> Namespace definition for "xsi" prefix is missed. And the receiver fails to process the message because of validation.
> EXPECTED RESULT:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
>     <myOperation xmlns="http://sandbox.org/services/MyService/myOperation">
>         <data>
>             <oneElement xmlns="http://sandbox.org/datatypes/one">
>                 <twoElement xmlns="http://sandbox.org/datatypes/two" 
>                             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>                             xsi:nil="true"/>
>             </oneElement>
>         </data>
>     </myOperation>
> </soap:Body>
> </soap:Envelope>
> I.e. the namespace for "xsi" prefix is present.
> ANALYSIS:
> Analysis is based on the CXF 2.2.3.
> Please have a look at the sources:
>    Class: org.apache.cxf.staxutils.StaxUtils
>    Method: writeStartElement(XMLStreamReader reader, XMLStreamWriter writer)
>    The code under his comment -> // Write out attributes
> My guess is:
>    If we have both "ns" and "nsPrefix" that are not empty then the namespace definition should be written.
>    506            } else {
>    507                writer.writeNamespace(nsPrefix, ns); // <-- THIS IS A NEW EXAMPLE LINE OF WHAT IS DESIRED
>    508                writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader
>    509                    .getAttributeLocalName(i), reader.getAttributeValue(i));
>    510            }

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