0 Replies Latest reply on Jan 8, 2015 12:37 PM by Narayanan HariharaSubramanian

    CXF Xmlbeans namespace issue using Abstract types

    Narayanan HariharaSubramanian Newbie

      I am using a CXF client with XmlBeans databinding in my application and I am constructing request using XSLT and here is the Xml request.

       

          <complainceRequest 
          xmlns="http://www.mycompany.com/compliancedetails/1/" 
          xmlns:ns1="http://www.mycompany.com/identifier/types/1/" 
          xmlns:ns2="http://www.mycompany.com/identifier/1/" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <identifiers xsi:type="ns1:IdentifiersType">
             <ns1:identifier>
                <ns1:sourceSystem>
                   <ns2:identifier>159683741985871</ns2:identifier>
                   <ns2:locationCode>CED</ns2:locationCode>
                </ns1:sourceSystem>
             </ns1:identifier>
          </identifiers>
      </complainceRequest>
      

      As you can see the namespace prefix "ns1" used in element "identifiers" is defined at the root level.

       

      But when sending this XmlBeans object into CXF client, the generated soap request has namespaces defined inline instead of at the root level.

       

          <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
          <soap:Body>
              <complainceRequest xmlns="http://www.mycompany.com/compliancedetails/1/">
                  <identifiers xsi:type="ns1:IdentifiersType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                     <ns1:identifier xmlns:ns1="http://www.mycompany.com/identifier/types/1/">
                        <ns1:sourceSystem>
                           <ns2:identifier xmlns:ns2="http://www.mycompany.com/identifier/1/">159683741985871</ns2:identifier>
                           <ns2:locationCode xmlns:ns2="http://www.mycompany.com/identifier/1/">CED</ns2:locationCode>
                        </ns1:sourceSystem>
                     </ns1:identifier>
                  </identifiers>
              </complainceRequest>
          </soap:Body>
      </soap:Envelope>
      

      The namespace for prefix 'ns1' is defined only at element "ns1:identifier" even though it is used as an abstract type in a top level element "identifiers". this is causing schema validation issues while calling the web service.

       

      Is there anyway, I can stop inline namespaces and use xml request as is?

       

      The workaround I have in place is to define 'ns1' in soap.env.ns.map property which is working fine.

       

        <entry key="soap.env.ns.map">
          <map>
              <entry key="ns1" value="http://www.mycompany.com/identifier/types/1/" />
          </map>
      </entry>
      

      But is there anyway to stop this behavior?  Thanks for the help.