Hello again.
Sorry, for posting again, but it seems my digital signature cause problem. Did 
not expect that.

Lars

> Hi all.
> 
> Sorry for cross posting. I already asked this question on Stack Overflow
> before I found the mailing list:
> https://stackoverflow.com/questions/52716828/apache-camel-jaxb-unmarshalling-
> returns-null-properties-after-upgrade-from-camel
> 
> After upgrading Apache Camel from 2.20.4 to 2.21.2 or even 2.22.1 a unit test
> of my fails and I can't see why.
> 
> I have a route, which receives an XML response, which I want to unmarshal into
> a data class. This fails since Apache Camel 2.21.2.
> 
> The JAXB context knows all data classes in the given package and picks the
> right class. The unmarshaller creates the right object, but the properties
> stay null. With debugging the SAX parser, it seemed as if the SAX parser
> deliberately ignores the text between the tags.
> 
> I have seen on the Camel website that Camel 2.21.0 "Upgraded to JAXB 2.3.0". I
> don't know what that means for me.
> 
> My route looks like this:
> 
> @Component
> public class NewsletterRoute extends RouteBuilder {
> 
> 8<-------------------------------------------------
> 
> @Override
> public void configure() {
>     final DataFormat marshalFormat =
>         new JacksonDataFormat(HybrisRequest.class);
>     final JaxbDataFormat unmarshalFormat = new JaxbDataFormat();
>     unmarshalFormat.setContextPath(
>        SuccessResponse.class.getPackage().getName());
> 
>     from(URI)
>         .routeId("subscribeRoute")
>         // Fetch the auth token to send it as 'x-csrf-token' header.
>         .setHeader(Exchange.HTTP_URI,
>             method(this.backendUrlProvider, "getUrl"))
>         .setHeader(Exchange.HTTP_PATH,
>              constant(this.subscribeUnsubscribePath))
>         .setHeader(Exchange.HTTP_METHOD, HttpMethods.POST)
>         .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
>         // Marshal body to JSON
>         .marshal(marshalFormat)
>         .to(String.format("https4:backend" +
>                 "?sslContextParameters=hybrisSslContextParams" +
>                 "&x509HostnameVerifier=hybrisHostnameVerifier" +
>                 // don't throw on 3XX/4XX/5XX since
>                 // we need the response body
>                 "&throwExceptionOnFailure=false" +
>                 "&cookieStore=#hybrisCookieStore" +
>                 "&authUsername=%s" +
>                 "&authPassword=%s" +
>                 "&authenticationPreemptive=true" +
>                 "&httpClient.redirectsEnabled=true" +
>                 "&httpClient.maxRedirects=3" +
>                 "&httpClient.connectTimeout=%d" +
>                 "&httpClient.socketTimeout=%d",
>             "RAW(" + username + ")",
>             "RAW(" + password + ")",
>             backendTimeoutMillis,
>             backendTimeoutMillis))
>         .convertBodyTo(String.class)
>         // Store the received response as property before
>         // trying to unmarshal it
>         .setProperty(PROPERTY_RESPONSE_RAW, body())
>         .unmarshal(unmarshalFormat);
>     // @formatter:on
>     }
> }
> 
> 
> The data class looks like this
> 
> @XmlRootElement(name = "entry", namespace = "http://www.w3.org/2005/Atom";)
> public class SuccessResponse {
>     private String id;
>     private String title;
>     public String getId() { return id; }
>     public void setId(String id) { this.id = id; }
>     public String getTitle() { return title; }
>     public void setTitle(String title) { this.title = title; }
>     public String toString() { /*code cut out*/}
> }
> 
> 
> With Apache Camel 2.20.4 my unit test worked. With 2.21.2 and 2.22.1 it
> breaks. The problem is, that the unmarshaler won't fill the properties.
> 
> The unit test just sends a valid request to Mockito, which returns the XML.
> 
> <?xml version="1.0" encoding="utf-8"?>
> <entry
> xml:base="https://xxx.xxx.xxx.xxx:44380/sap/opu/odata/sap/CUAN_IMPORT_SRV
> /"
>     xmlns="http://www.w3.org/2005/Atom";
>     xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
>     xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices";>
> <!-- 8<---------- Code cut out here ----------------------------------- -->
>     <id>bla</id>
>     <title type="text">blub</title>
> </entry>
> 
> 
> Any ideas?
> 
> Thanks
> Lars

Reply via email to