1 Reply Latest reply on Feb 17, 2010 11:43 AM by Thomas Letsch

    Problem with HTTP inbound -> HTTP outbound bridging

    Thomas Letsch Newbie

      I want to bridge a HTTP POST request with an XML content to an HTTP endpoint with the same request body. The headers are not relevant for me.

       

      The problem is, that the outbound HTTP request is malformed, the former body content is no longer a HTTP content, but is sent as header (missing CTLF seperator between the real header and the content).

       

      Any ideas why this happens?

       

      Thanks,

      Thomas

       

      This is my configuration (beans.xml):

            

       

       

      The logfile shows the wrong HTTP request:

      heckpoint Worker | MessageDatabase                  | emq.store.kahadb.MessageDatabase  959 | Checkpoint started.

      heckpoint Worker | MessageDatabase                  | emq.store.kahadb.MessageDatabase 1045 | Checkpoint done.

      l Console Thread | ServiceRecipe                    | lueprint.container.ServiceRecipe  225 | Retrieving service for bundle org.apache.felix.gogo.runtime_0.2.2 and service registration {org.apache.felix.karaf.shell.console.CompletableFunction, org.osgi.service.command.Function}={osgi.command.function=set, osgi.command.scope=log, service.id=64}

      l Console Thread | BlueprintContainerImpl           | container.BlueprintContainerImpl  680 | Instantiating component shell-11

      l Console Thread | BlueprintContainerImpl           | container.BlueprintContainerImpl  680 | Instantiating component blueprintBundleContext

      l Console Thread | configadmin                      | ?                                   ? | Scheduling task Update: pid=org.ops4j.pax.logging

      guration Updater | configadmin                      | ?                                   ? | Running task Update: pid=org.ops4j.pax.logging

      guration Updater | configadmin                      | ?                                   ? | Scheduling task Fire ConfigurationEvent: pid=org.ops4j.pax.logging

      guration Updater | configadmin                      | ?                                   ? | Running task Fire ConfigurationEvent: pid=org.ops4j.pax.logging

      heckpoint Worker | MessageDatabase                  | emq.store.kahadb.MessageDatabase  959 | Checkpoint started.

      heckpoint Worker | MessageDatabase                  | emq.store.kahadb.MessageDatabase 1045 | Checkpoint done.

      - /sepa/request | jetty                            | .service.internal.util.JCLLogger   85 | REQUEST /sepa/request on org.mortbay.jetty.HttpConnection@346064

      - /sepa/request | jetty                            | .service.internal.util.JCLLogger   85 | servlet=org.apache.camel.component.http.CamelServlet-27788977

      - /sepa/request | jetty                            | .service.internal.util.JCLLogger   85 | chain=null

      - /sepa/request | jetty                            | .service.internal.util.JCLLogger   85 | servlet holder=org.apache.camel.component.http.CamelServlet-27788977

      - /sepa/request | HttpProducer                     | amel.component.http.HttpProducer   76 | Executing http POST method: http://localhost:7011/sepa/request/

      - /sepa/request | ltiThreadedHttpConnectionManager | ltiThreadedHttpConnectionManager  412 | HttpConnectionManager.getConnection:  config = HostConfiguration[host=http://localhost:7011], timeout = 0

      - /sepa/request | ltiThreadedHttpConnectionManager | ConnectionManager$ConnectionPool  839 | Getting free connection, hostConfig=HostConfiguration[host=http://localhost:7011]

      - /sepa/request | HttpConnection                   | ommons.httpclient.HttpConnection  692 | Open connection to localhost:7011

      - /sepa/request | header                           | g.apache.commons.httpclient.Wire   70 | >> "POST /sepa/request/ HTTP/1.1[\r][\n]"

      - /sepa/request | HttpMethodBase                   | ommons.httpclient.HttpMethodBase 1352 | Adding Host request header

      - /sepa/request | header                           | g.apache.commons.httpclient.Wire   70 | >> "connection: close[\r][\n]"

      - /sepa/request | header                           | g.apache.commons.httpclient.Wire   70 | >> "user-agent: Jakarta Commons-HttpClient/3.1[\r][\n]"

      - /sepa/request | header                           | g.apache.commons.httpclient.Wire   70 | >> " "[\r][\n]"

      - /sepa/request | EntityEnclosingMethod            | nt.methods.EntityEnclosingMethod  508 | Request body sent

      - /sepa/request | header                           | g.apache.commons.httpclient.Wire   70 | << "HTTP/1.1 400 Bad Request[\r][\n]"

      - /sepa/request | header                           | g.apache.commons.httpclient.Wire   70 | << "HTTP/1.1 400 Bad Request[\r][\n]"

      - /sepa/request | header                           | g.apache.commons.httpclient.Wire   70 | << "Connection: close[\r][\n]"

      - /sepa/request | header                           | g.apache.commons.httpclient.Wire   70 | << "Server: Jetty(7.0.1.v20091125)[\r][\n]"

      - /sepa/request | header                           | g.apache.commons.httpclient.Wire   70 | << "[\r][\n]"

      - /sepa/request | HttpProducer                     | amel.component.http.HttpProducer   80 | Http responseCode: 400

      - /sepa/request | HttpMethodBase                   | ommons.httpclient.HttpMethodBase 1008 | Should close connection in response to directive: close

      - /sepa/request | HttpConnection                   | ommons.httpclient.HttpConnection 1178 | Releasing connection back to connection manager.

      - /sepa/request | ltiThreadedHttpConnectionManager | ConnectionManager$ConnectionPool  979 | Freeing connection, hostConfig=HostConfiguration[host=http://localhost:7011]

      - /sepa/request | IdleConnectionHandler            | lient.util.IdleConnectionHandler   76 | Adding connection at: 1266310944788

      - /sepa/request | ltiThreadedHttpConnectionManager | ConnectionManager$ConnectionPool  961 | Notifying no-one, there are no waiting threads

      - /sepa/request | DefaultErrorHandler              | rg.apache.camel.processor.Logger  197 | Failed delivery for exchangeId: 275504e1-ce1d-41b6-82e9-d5a35426e2f4. On delivery attempt: 0 caught: org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http://localhost:7011/sepa/request/ with statusCode: 400

      - /sepa/request | DefaultErrorHandler              | processor.RedeliveryErrorHandler  411 | This exchange is not handled so its marked as failed: Exchange[Message: ]

      - /sepa/request | Pipeline                         | .apache.camel.processor.Pipeline   99 | Message exchange has failed so breaking out of pipeline: Exchange[Message: ] Exception: org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http://localhost:7011/sepa/request/ with statusCode: 400

      - /sepa/request | jetty                            | .service.internal.util.JCLLogger   85 | RESPONSE /sepa/request  500

        • 1. Re: Problem with HTTP inbound -> HTTP outbound bridging
          Thomas Letsch Newbie

          I found out myself:

          The problem is inside the sevlet processing in JETTY. The xml content gets parsed as parameter and is therefore no longer available as message content.

          instead it is contained in a parameter / header field and sent as such.

           

          This behaviour is described in some foum / tickets in JETTY and is conform to the servlet spec. Even if I do not use any of the servlet stuff, the params get parsed.

           

          To prevent this, one has to change the content-type of the HTTP request. Mine was x-www-url-encoded, because I used JMeter as a test client. Unfortunately JMeter can only switch betweed multipart content type or the x-www-url-encoded.

           

          I now use some unit tests with HTTPClient and it works.