The following line is what's causing you the problem:
JAXB.unmarshal(sm.toString(), SearchFlightsResponse.class);
The result of sm.toString()
is going to be something like the following and not a String
representation of the XML.
com.sun.xml.internal.messaging.saaj.soap.ver1_2.Message1_2Impl@693f23a2
What you are doing now is the equivalent of doing the following:
import javax.xml.bind.JAXB;
public class Demo {
public static void main(String[] args) throws Exception {
JAXB.unmarshal("com.sun.xml.internal.messaging.saaj.soap.ver1_2.Message1_2Impl@693f23a2", Foo.class);
}
}
Which will return the following exception:
Exception in thread "main" java.lang.IllegalArgumentException: URI is not absolute
at java.net.URI.toURL(URI.java:1095)
at javax.xml.bind.JAXB.toSource(JAXB.java:291)
at javax.xml.bind.JAXB.unmarshal(JAXB.java:205)
at forum23652823.Demo.main(Demo.java:8)
Note
The String
parameter in the JAXB.unmarshal(String, Class)
method is the location of the XML, and not the XML itself. This is why the exception is complaining about a URI.