Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-59

CastorMarshaller does not marshal to DOM trees correctly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0 M2
    • Fix Version/s: 1.0 M3
    • Component/s: OXM
    • Labels:
      None

      Description

      The CastorMarshaller does not create correct DOM trees. While marshalling to DOM nodes, castor uses a SAX2DOMHandler to publish SAX events into the DOM tree. This handler is a SAX 1 DocumentHandler, which has no native namespace support. There is a DocumentHandlerAdapter, which tries to correct this, but obviously that is failing.

      See http://forum.springframework.org/showthread.php?t=27476 and http://forum.springframework.org/showthread.php?t=28419

        Activity

        Hide
        mohanchandar mohanchandar added a comment -

        Hi,
        we are struggling with CASTOR marcchalling for executing a service request. we are seeing DOMException: NAMESPACE_ERR exception. So thought this might the right place to post this...

        Mapping XML:

        <?xml version="1.0"?>
        <mapping>

        <!-- Request Elements -->

        <class name="com.fmr.fiis.springws.TransactionHistoryDetailRequestBean">
        <map-to xml="srvc:TransactionMonetaryInquireSingle" xmlns:srvc="http://www.fmr.com/fiis/1.0/fiis-services"/>
        <field name="orgTaNo" type="java.lang.String">
        <bind-xml name="data:OrgTaNo" node="element" xmlns:data="http://www.fmr.com/fiis/1.0/fiis-data"/>
        </field>
        <field name="accountNo" type="java.lang.String">
        <bind-xml name="data:AccntTaNo" node="element" location="data:AccountTaRef" xmlns:data="http://www.fmr.com/fiis/1.0/fiis-data"/>
        </field>
        <field name="fundNo" type="java.lang.String">
        <bind-xml name="data:FundNo" node="element" location="data:FundRef" xmlns:data="http://www.fmr.com/fiis/1.0/fiis-data"/>
        </field>
        <field name="topsConfirmNo" type="java.lang.String">
        <bind-xml name="data:TopsConfirmNo" node="element" xmlns:data="http://www.fmr.com/fiis/1.0/fiis-data"/>
        </field>
        <field name="transactionId" type="java.lang.String">
        <bind-xml name="data:TransactionIdTx" node="element" xmlns:data="http://www.fmr.com/fiis/1.0/fiis-data"/>
        </field>
        </class>
        </mapping>

        Actual XML Expected:
        When executed throught plain java class in local JRE it works fine and gives below response.
        <SOAP-ENV:Body>
        <srvc:TransactionMonetaryInquireSingle>
        <data:AccountTaRef>
        <data:AccntTaNo></data:AccntTaNo>
        </data:AccountTaRef>
        <data:FundRef>
        <data:FundNo></data:FundNo>
        </data:FundRef>
        <data:TransactionIdTx></data:TransactionIdTx>
        </srvc:TransactionMonetaryInquireSingle>
        </SOAP-ENV:Body>

        Problem:
        When deployed in websphere portal server and when the service is called, we are facing below problems:

        Note that TransactionMonetaryInquireSingle element should have "srvc" prefix and others should have "data" as prefix
        1) If i mention srvc:TransactionMonetaryInquireSingle and namespace xmlns:srvc="http://www.fmr.com/fiis/1.0/fiis-services" in <map-to> it throws below error.

        "Get descriptor for: com.fmr.fiis.afc.accounts.requestresponse.TransactionHistoryDetailRequestBean found: [email protected]; descriptor for class: com.fmr.fiis.afc.accounts.requestresponse.TransactionHistoryDetailRequestBean; xml name: srvc:TransactionMonetaryInquireSingle

        Service org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces."

        2) If I mention - ns-uri="http://www.fmr.com/fiis/1.0/fiis-services" ns-prefix="srvc" instead of xml="srvc:TransactionMonetaryInquireSingle" in <map-to> srvc prefix gets appended for TransactionMonetaryInquireSingle and AccountTaRef elements (since AccountTaRef is mentioned as location attribute it applies the parent prefix to this also). It generates XML as below which has wrong prefix for AccountTaRef

        <SOAP-ENV:Body>
        <srvc:TransactionMonetaryInquireSingle>
        <srvc:AccountTaRef>
        <data:AccntTaNo></data:AccntTaNo>
        </srvc:AccountTaRef>
        <srvc:FundRef>
        <data:FundNo></data:FundNo>
        </srvc:FundRef>
        <data:TransactionIdTx></data:TransactionIdTx>
        </srvc:TransactionMonetaryInquireSingle>
        </SOAP-ENV:Body>

        Could anyone please help with this? we are really confused why it is working with local JRE and not in the server.

        Show
        mohanchandar mohanchandar added a comment - Hi, we are struggling with CASTOR marcchalling for executing a service request. we are seeing DOMException: NAMESPACE_ERR exception. So thought this might the right place to post this... Mapping XML: <?xml version="1.0"?> <mapping> <!-- Request Elements --> <class name="com.fmr.fiis.springws.TransactionHistoryDetailRequestBean"> <map-to xml="srvc:TransactionMonetaryInquireSingle" xmlns:srvc="http://www.fmr.com/fiis/1.0/fiis-services"/> <field name="orgTaNo" type="java.lang.String"> <bind-xml name="data:OrgTaNo" node="element" xmlns:data="http://www.fmr.com/fiis/1.0/fiis-data"/> </field> <field name="accountNo" type="java.lang.String"> <bind-xml name="data:AccntTaNo" node="element" location="data:AccountTaRef" xmlns:data="http://www.fmr.com/fiis/1.0/fiis-data"/> </field> <field name="fundNo" type="java.lang.String"> <bind-xml name="data:FundNo" node="element" location="data:FundRef" xmlns:data="http://www.fmr.com/fiis/1.0/fiis-data"/> </field> <field name="topsConfirmNo" type="java.lang.String"> <bind-xml name="data:TopsConfirmNo" node="element" xmlns:data="http://www.fmr.com/fiis/1.0/fiis-data"/> </field> <field name="transactionId" type="java.lang.String"> <bind-xml name="data:TransactionIdTx" node="element" xmlns:data="http://www.fmr.com/fiis/1.0/fiis-data"/> </field> </class> </mapping> Actual XML Expected: When executed throught plain java class in local JRE it works fine and gives below response. <SOAP-ENV:Body> <srvc:TransactionMonetaryInquireSingle> <data:AccountTaRef> <data:AccntTaNo></data:AccntTaNo> </data:AccountTaRef> <data:FundRef> <data:FundNo></data:FundNo> </data:FundRef> <data:TransactionIdTx></data:TransactionIdTx> </srvc:TransactionMonetaryInquireSingle> </SOAP-ENV:Body> Problem: When deployed in websphere portal server and when the service is called, we are facing below problems: Note that TransactionMonetaryInquireSingle element should have "srvc" prefix and others should have "data" as prefix 1) If i mention srvc:TransactionMonetaryInquireSingle and namespace xmlns:srvc="http://www.fmr.com/fiis/1.0/fiis-services" in <map-to> it throws below error. "Get descriptor for: com.fmr.fiis.afc.accounts.requestresponse.TransactionHistoryDetailRequestBean found: [email protected]; descriptor for class: com.fmr.fiis.afc.accounts.requestresponse.TransactionHistoryDetailRequestBean; xml name: srvc:TransactionMonetaryInquireSingle Service org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces." 2) If I mention - ns-uri="http://www.fmr.com/fiis/1.0/fiis-services" ns-prefix="srvc" instead of xml="srvc:TransactionMonetaryInquireSingle" in <map-to> srvc prefix gets appended for TransactionMonetaryInquireSingle and AccountTaRef elements (since AccountTaRef is mentioned as location attribute it applies the parent prefix to this also). It generates XML as below which has wrong prefix for AccountTaRef <SOAP-ENV:Body> <srvc:TransactionMonetaryInquireSingle> <srvc:AccountTaRef> <data:AccntTaNo></data:AccntTaNo> </srvc:AccountTaRef> <srvc:FundRef> <data:FundNo></data:FundNo> </srvc:FundRef> <data:TransactionIdTx></data:TransactionIdTx> </srvc:TransactionMonetaryInquireSingle> </SOAP-ENV:Body> Could anyone please help with this? we are really confused why it is working with local JRE and not in the server.

          People

          • Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            arjen.poutsma Arjen Poutsma
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: