AW: Camel .toD() adding extra CamelHttpPath to target URL?

2020-10-20 Thread Lars Schaps
Hi Claus.

Thanks for your answer.

Actually I tried that already while waiting for an answer - I emptied it, but 
felt a bit naughty. Didn't know if that’s the proper way to do it.

Lars


-Ursprüngliche Nachricht-
Von: Claus Ibsen  
Gesendet: Dienstag, 20. Oktober 2020 15:07
An: users@camel.apache.org
Betreff: Re: Camel .toD() adding extra CamelHttpPath to target URL?

Hi

If you do some from http to http proxy thingy, then it can often make better to 
remove existing CamelHttp headers before calling to / toD to clear those from 
interfering. There was a FAQ about this on the old website, not sure if it was 
migrated to the new.

On Tue, Oct 20, 2020 at 2:50 PM Lars Schaps  wrote:
>
> Hello Maillinglist
>
> I have a question/problem regarding the .toD feature to dynamically 
> set the endpoint for the http(s) protocol
>
> In my example call I have
>
> .toD("${exchangeProperty.rewrite}")
>
> With rewrite set to
>
> https://exampledomain/en/reminder-webservice-v2/reminder/offerDate/?th
> rowExceptionOnFailure=false=1
> .socketTimeout=1=true=mySSLCon
> textParameters
>
> The command
>
>.to("log:INFO?showBody=true=true");
>
> after the .toD() is showing me following output:
>
> 2020-10-20 13:23:57,143 [T:http-nio-8080-exec-3, C:test] INFO | 
> Exchange[ExchangePattern: InOut, Headers: {accept=*/*, 
> accept-encoding=gzip,deflate, CamelHttpCharacterEncoding=ISO-8859-1, 
> CamelHttpMethod=POST,   CamelHttpPath=/au/offerDate, 
> CamelHttpResponseCode=301, CamelHttpResponseText=X RealURL redirect, 
> CamelHttpServletRequest=org.apache.catalina.connector.RequestFacade@12dcf186, 
> 
> CamelHttpServletResponse=org.apache.catalina.connector.ResponseFacade@180c0467,
>  CamelHttpUri=/proxy/v2/reminder/au/offerDate, 
> CamelHttpUrl=http://exampledomain/proxy/v2/reminder/au/offerDate, 
> CamelServletContextPath=/v2/reminder, Connection=keep-alive, 
> Content-Length=0, Content-Type=text/html; charset=UTF-8, Date=Tue, 20 Oct 
> 2020 11:23:57 GMT, Location=https://exampledomain/en/reminder-webservice- 
>v2/reminder/offerDate/au/offerDate/, Server=nginx, 
> Strict-Transport-Security=max-age=31536000, X-Content-Type-Options=nosniff, 
> X-TYPO3-RealURL-Info=redirect for missing slash, X-XSS-Protection=1; 
> mode=block}, BodyType:  
> org.apache.camel.converter.stream.CachedOutputStream.WrappedInputStream, 
> Body: [Body is instance of java.io.InputStream]]
>
> I expect the target host to receive a request
>
>
> https://exampledomain/en/reminder-webservice-v2/reminder/offerDate/
>
> like it was set via .toD(), but instead it receives (like in 
> "Location" of the log message)
>
>
> https://exampledomain/en/reminder-webservice-v2/reminder/offerDate/au/
> offerDate/
>
> with an extra
>
>au/offerDate
>
> Which causes trouble.
>
> What am I doing wrong and how can I fix this?
>
> Camel 3.4.3
> Tomcat 8.5
> Java 8 openjdk
>
> Kind regards
> Lars
>


--
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


smime.p7s
Description: S/MIME cryptographic signature


Camel .toD() adding extra CamelHttpPath to target URL?

2020-10-20 Thread Lars Schaps
Hello Maillinglist

I have a question/problem regarding the .toD feature to dynamically set the 
endpoint for the http(s) protocol

In my example call I have

.toD("${exchangeProperty.rewrite}")

With rewrite set to

https://exampledomain/en/reminder-webservice-v2/reminder/offerDate/?throwExceptionOnFailure=false=1=1=true=mySSLContextParameters

The command

   .to("log:INFO?showBody=true=true");

after the .toD() is showing me following output:

2020-10-20 13:23:57,143 [T:http-nio-8080-exec-3, C:test] INFO | 
Exchange[ExchangePattern: InOut, Headers: {accept=*/*, 
accept-encoding=gzip,deflate, CamelHttpCharacterEncoding=ISO-8859-1, 
CamelHttpMethod=POST,   CamelHttpPath=/au/offerDate, 
CamelHttpResponseCode=301, CamelHttpResponseText=X RealURL redirect, 
CamelHttpServletRequest=org.apache.catalina.connector.RequestFacade@12dcf186,   
  
CamelHttpServletResponse=org.apache.catalina.connector.ResponseFacade@180c0467, 
CamelHttpUri=/proxy/v2/reminder/au/offerDate, 
CamelHttpUrl=http://exampledomain/proxy/v2/reminder/au/offerDate, 
CamelServletContextPath=/v2/reminder, Connection=keep-alive, Content-Length=0, 
Content-Type=text/html; charset=UTF-8, Date=Tue, 20 Oct 2020 11:23:57 GMT, 
Location=https://exampledomain/en/reminder-webservice-
v2/reminder/offerDate/au/offerDate/, Server=nginx, 
Strict-Transport-Security=max-age=31536000, X-Content-Type-Options=nosniff, 
X-TYPO3-RealURL-Info=redirect for missing slash, X-XSS-Protection=1; 
mode=block}, BodyType:  
org.apache.camel.converter.stream.CachedOutputStream.WrappedInputStream, Body: 
[Body is instance of java.io.InputStream]]

I expect the target host to receive a request

   https://exampledomain/en/reminder-webservice-v2/reminder/offerDate/

like it was set via .toD(), but instead it receives (like in "Location" of the 
log message)

   
https://exampledomain/en/reminder-webservice-v2/reminder/offerDate/au/offerDate/

with an extra

   au/offerDate

Which causes trouble.

What am I doing wrong and how can I fix this?

Camel 3.4.3
Tomcat 8.5
Java 8 openjdk

Kind regards
Lars



RE: Apache Camel JAXB unmarshalling returns null properties after upgrade from Camel from 2.20.4 to 2.21.2 or 2.22.1

2018-10-10 Thread Lars Schaps
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" +
> "=hybrisHostnameVerifier" +
> // don't throw on 3XX/4XX/5XX since
> // we need the response body
> "=false" +
> "=#hybrisCookieStore" +
> "=%s" +
> "=%s" +
> "=true" +
> "=true" +
> "=3" +
> "=%d" +
> "=%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: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;>
> 
> bla
> blub
> 
> 
> 
> Any ideas?
> 
> Thanks
> Lars


Apache Camel JAXB unmarshalling returns null properties after upgrade from Camel from 2.20.4 to 2.21.2 or 2.22.1

2018-10-10 Thread Lars Schaps


smime.p7m
Description: S/MIME encrypted message