JAXB: default namespace declared in SOAP Envelop is not recognized in Body's xsi:type while unmarshalling

511 Views Asked by At

Below is a pseudo soap response coming from the server as below.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn://tsys.com/xmlmessaging/T1">
<soap:Header>
  <Header details/>
</soap:Header>
<soap:Body>
  <inqMultiResponse>
     <inqMultiResult status="000" statusMsg="passed" >
        <inquireResult xsi:type="inqCustAddrResponseType" >
           <addrInfo>
              <addrType>Primary</addrType>
                ....
              <x_4.0.0/>
           </addrInfo>
        </inquireResult>
        <inquireResult xsi:type="inqGeneralAcctResponseType" status="000" statusMsg="passed">
           <acctGeneralInfo>
              <type>Z</type>
                ....
              </stmtInfo>
              <x_4.4.0/>
           </acctGeneralInfo>
        </inquireResult>
     </inqMultiResult>
  </inqMultiResponse>
</soap:Body>

While unmarshalling the xml using JAXB's Jaxb2Marshaller, i get the following exception in my EventHandler.

EVENT
SEVERITY:  1
MESSAGE:  unrecognized type name: inqCustAddrResponseType. Did you mean {urn://tsys.com/xmlmessaging/T1}inqCustAddrResponseType?
LINKED EXCEPTION:  null
LOCATOR
    LINE NUMBER:  -1
    COLUMN NUMBER:  -1
    OFFSET:  -1
    OBJECT:  null
    NODE:  [inquireResult: null]
    URL:  null

EVENT
SEVERITY:  2
MESSAGE:  Unable to create an instance of com.tsys.xmlmessaging.t1.TSYSInquiryResponseType
LINKED EXCEPTION:  java.lang.InstantiationException
    LOCATOR
    LINE NUMBER:  -1
    COLUMN NUMBER:  -1
    OFFSET:  -1
    OBJECT:  null
    NODE:  [inquireResult: null]
    URL:  null

Below is my spring configuration.

<bean id="tsysTransactionMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    <property name="validationEventHandler" ref="validationEventHandler" />
    <property name="contextPaths">
        <list>
            <value>com.tsys.xmlmessaging.t1</value>
        </list>
    </property>
</bean>

Request you to pls help me unmarshall the xml.

I have gone through various suggestions like JAXB xsi:type subclass unmarshalling not working and Blaise D blogs, but none of them talk of using it with Jaxb2Marshaller as in my case.

Please note,
- The classes are generated using XJC. Not including here to ensure that i dont clutter with unnecessary information. let me know if more info is required.
- We are not having any control on the xml soap response sent from server and hence we may not be able to change them.

0

There are 0 best solutions below