Ignoring xml namespace during unmarshalling in RestTemplate

Viewed 1334

I am sending XML over HTTP request through Spring RestTemplate to an external gateway and I'm receiving a XML response back.

The XSD which was given to validate the response has a target namespace but the actual response doesn't contain the namespace prefix. I have generated the Java resources using the XSD and due to this I'm getting below error when getting response from (during the unmarshalling process),

ResponseEntity<Response> responseEntity = restTemplate.exchange(endpointURL, HttpMethod.POST, requestEntity,
                Response.class);

The exception is:-

Exception in thread "main" javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"Response"). Expected elements are <{http://securetransport.dw/rcservice/xml}Response>

Are there any ways to skip the namespace check from Spring ResponseEntity?

1 Answers
Related