7 Replies Latest reply on Apr 11, 2011 10:40 AM by Willem Jiang

    Body empty?

    Michele Dicerto Newbie

      Hi all,

      I've a problem with camel converting from rest to soap request.

      Basically I expose a REST service, I modify the client request and I convert it to a SOAP request for the external service.

      I use a TCP monitor tool and request/response are fine but if it seems that after the TCP monitor the response is lost as if I try to access the body or I try to visualize the result in a browser I've an empty response.

       

      from(Constant.LOCAL_ESB_REST_SEARCH)

           .choice()

             .when(...) doSomething

             .when(new isCompetence())                    

                       .to("direct:competences");

       

      from("direct:competences")

           .process(new prepareRequestForCompetences())

           .setHeader("CamelHttpMethod", constant("POST"))

           .to(Constant.COMPETENCE_SERVICE+"?bridgeEndpoint=true&throwExceptionOnFailure=false")  <--- here the body is empty

       

      Any idea?

       

      Thanks,

       

      Michele

        • 1. Re: Body empty?
          Michele Dicerto Newbie

          just to help to understand, the response froom server monitored by the tcp viewer  is:

           

           

          284: Server to Client (2920 bytes, Incomplete last line)

          HTTP/1.1 200 OK

          X-Powered-By: Servlet/2.5

          Server: Sun Java System Application Server 9.1_02

          Content-Type: text/xml;charset="utf-8"

          Transfer-Encoding: chunked

          Date: Tue, 29 Mar 2011 10:53:33 GMT

           

          2000

          &lt;competences&gt;&lt;competence id=&quot;239&quot;&gt;&lt;title&gt;SWOT analysis&lt;/title&gt;&lt;description&gt;Being able to apply SWOT analysis&lt;/description&gt;&lt;resources&gt;&lt;resource id=&quot;15&quot;&gt;&lt;competenceID&gt;239&lt;/competenceID&gt;&lt;userID&gt;michele&lt;/userID&gt;&lt;name&gt;Google&lt;/name&gt;&lt;uri&gt;http://www.google.it</uri><minEQF>0</minEQF><maxEQF>0</maxEQF></resource><resource id=&quot;16&quot;&gt;&lt;competenceID&gt;239&lt;/competenceID&gt;&lt;userID&gt;michele&lt;/userID&gt;&lt;name&gt;Google&lt;/name&gt;&lt;uri&gt;http://www.google.it</uri><minEQF>0</minEQF><maxEQF>0</maxEQF></resource></resources></competence><competence id=&quot;238&quot;&gt;&lt;title&gt;Sales Techniques&lt;/title&gt;&lt;description&gt;Being able to apply different sales techniques&lt;/description&gt;&lt;/competence&gt;&lt;competence id=&quot;237&quot;&gt;&lt;title&gt;Marketing channels&lt;/title&gt;&lt;description&gt;Being able to manage different marketing channels&lt;/description&gt;&lt;/competence&gt;&lt;competence id=&quot;236&quot;&gt;&lt;title&gt;Customer Relationship Management&lt;/title&gt;&lt;description&gt;Being able to setup and manage customer-relationship management&lt;/description&gt;&lt;/competence&gt;&lt;competence id=&quot;234&quot;&gt;&lt;title&gt;Distribution network&lt;/title&gt;&lt;description&gt;Being able to optimize the distribution network&lt;/description&gt;&lt;/competence&gt;&lt;competence id=&quot;235&quot;&gt;&lt;title&gt;Product placement&lt;/title&gt;&lt;description&gt;Being able to position a product on the market&lt;/description&gt;&lt;/competence&gt;&lt;competence id=&quot;232&quot;&gt;&lt;title&gt;Market research&lt;/title&gt;&lt;description&gt;Being able to conduct market research&lt;/description&gt;&lt;/competence&gt;&lt;competence id=&quot;233&quot;&gt;&lt;title&gt;Price policy&lt;/title&gt;&lt;description&gt;Being able to evaluate and adapt the price policy&lt;/description&gt;&lt;/competence&gt;&lt;competence id=&quot;231&quot;&gt;&lt;title&gt;To be able to apply interpersonal skills interculturally; the sending and receiving of messages that are accurate and appropriate&lt;/title&gt;&lt;description&gt;To be able to apply interpersonal skills interculturally; the sending and receiving of messages that are accurate and appropriate&lt;/description&gt;&lt;/competence&gt;&lt;competence id=&quot;230&quot;&gt;&lt;title&gt;To be able to achieve

          284: Server to Client (2920 bytes)

          0000  67 6F 61 6C 73 20 74 6F  73 6F 6D 65 20 64 65 67  goals tosome deg

          0010  72 65 65 20 74 68 72 6F  75 67 68 20 63 6F 6E 73  ree through cons

          0020  74 72 75 63 74 69 76 65  69 6E 74 65 72 61 63 74  tructiveinteract

          0030  69 6F 6E 20 69 6E 20 61  6E 20 69 6E 74 65 72 63  ion in an interc

          • 2. Re: Body empty?
            Michele Dicerto Newbie

            Hi,

             

            any idea on how try to solve this issue?

             

            best,

             

            Michele

            • 3. Re: Body empty?
              Willem Jiang Master

              What kind of browser are you using?

              Safari cannot display the xml rightly.

               

              According to your description, I can't tell how you put the TCP monitor tool to monitor the request/response. Did you monitor the request/response of the REST service or the SOAP service?

               

              Willem

              • 4. Re: Body empty?
                Michele Dicerto Newbie

                I'm pretty sure that is not a browser problem.

                I tried anyway with firefox,IE and Chrome.

                 

                But I can see the problem in camel also trying to add a processor after the  .to(rest) call.

                 

                from("direct:competences")

                .process(new prepareRequestForCompetences())

                .setHeader("CamelHttpMethod", constant("POST"))

                .to(Constant.COMPETENCE_SERVICE+"?bridgeEndpoint=true&throwExceptionOnFailure=false") <--- here the body is empty

                 

                if I add  a processort after the last .to() I don't see anything in the exchange object.

                 

                The TCP monitor is placed to intercept the request to SOAP service and monitor the the response. Basically in the last .to call I send the request to the monitor and monitor fwd it to the real service after displaying the stream.

                 

                Both the request and response are fine. But after that ,the response is lost ( even removing the monitor )

                 

                Edited by: allanon76 on Mar 31, 2011 12:22 PM

                • 5. Re: Body empty?
                  Willem Jiang Master

                  Can you enable the trace[1] and check the log for it?

                  From the camel route that you show me , I can't tell any thing wrong.

                   

                  http://camel.apache.org/tracer.html

                   

                  Willem

                  • 6. Re: Body empty?
                    Michele Dicerto Newbie

                    Hi, this is what I've, but it does not help a lot... at least for me...

                     

                    15:43:32,720 | INFO  | Thread-50        | Tracer                           | rg.apache.camel.processor.Logger   88 | 72 - org.apache.camel.camel-core - 2.4.0.fuse-02-00 | 9be62531-a396-414a-8d61-2422d8c40a23 >>> (route1) from(http://0.0.0.0:8080/rest) --> choice <<< Pattern:InOut, Headers:{org.restlet.startTime=1302011012673, CamelHttpMethod=GET, service=competences, org.restlet.http.version=HTTP/1.1, CamelHttpUri=http://localhost:8080/rest/competences, org.restlet.http.headers=[Host: localhost:8080, User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0, Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8, Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3, Accept-Encoding: gzip, deflate, Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep-alive]}, BodyType:null, Body:null

                     

                    15:43:32,720 | INFO  | Thread-50        | Tracer                           | rg.apache.camel.processor.Logger   88 | 72 - org.apache.camel.camel-core - 2.4.0.fuse-02-00 | 9be62531-a396-414a-8d61-2422d8c40a23 >>> (route1) choice --> direct://competences <<< Pattern:InOut, Headers:{org.restlet.startTime=1302011012673, CamelHttpMethod=GET, service=competences, org.restlet.http.version=HTTP/1.1, CamelHttpUri=http://localhost:8080/rest/competences, org.restlet.http.headers=[Host: localhost:8080, User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0, Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8, Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3, Accept-Encoding: gzip, deflate, Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep-alive]}, BodyType:null, Body:null

                     

                    15:43:32,736 | INFO  | Thread-50        | Tracer                           | rg.apache.camel.processor.Logger   88 | 72 - org.apache.camel.camel-core - 2.4.0.fuse-02-00 | 9be62531-a396-414a-8d61-2422d8c40a23 >>> (route6) direct://competences --> com.els.os.camel.processor.prepareRequestForCompetences@8f5352 <<< Pattern:InOut, Properties:{CamelToEndpoint=direct://competences}, Headers:{org.restlet.startTime=1302011012673, CamelHttpMethod=GET, service=competences, org.restlet.http.version=HTTP/1.1, CamelHttpUri=http://localhost:8080/rest/competences, org.restlet.http.headers=[Host: localhost:8080, User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0, Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8, Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3, Accept-Encoding: gzip, deflate, Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep-alive]}, BodyType:null, Body:null

                     

                    15:43:32,736 | INFO  | Thread-50        | prepareRequestForCompetences     | sor.prepareRequestForCompetences   17 | 248 - camel - 0.0.1.SNAPSHOT | prepareRequestForCompetences

                     

                    15:43:32,751 | INFO  | Thread-50        | Tracer                           | rg.apache.camel.processor.Logger   88 | 72 - org.apache.camel.camel-core - 2.4.0.fuse-02-00 | 9be62531-a396-414a-8d61-2422d8c40a23 >>> (route6) direct://competences --> com.els.os.camel.processor.prepareRequestForCompetences@8f5352 <<< Pattern:InOut, Properties:{CamelToEndpoint=direct://competences}, Headers:{CamelHttpUri=http://localhost:8080/rest/competences, org.restlet.http.headers=[Host: localhost:8080, User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0, Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8, Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3, Accept-Encoding: gzip, deflate, Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep-alive], SOAPAction=, CamelHttpMethod=POST, Content-Type=text/xml;charset=UTF-8, org.restlet.startTime=1302011012673, service=competences, org.restlet.http.version=HTTP/1.1}, BodyType:String, Body: http://openscout.ou.nl:8080/OpenScout_Competence_Webservices/CompetenceServicesService?throwExceptionOnFailure=false&bridgeEndpoint=true <<< Pattern:InOut, Properties:{CamelToEndpoint=direct://competences}, Headers:{org.restlet.http.headers=[Host: localhost:8080, User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0, Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8, Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3, Accept-Encoding: gzip, deflate, Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep-alive], service=competences, org.restlet.startTime=1302011012673, CamelHttpUri=http://localhost:8080/rest/competences, CamelHttpMethod=POST, org.restlet.http.version=HTTP/1.1, SOAPAction=, Content-Type=text/xml;charset=UTF-8}, BodyType:String, Body: http://openscout.ou.nl:8080/OpenScout_Competence_Webservices/CompetenceServicesService?throwExceptionOnFailure=false&bridgeEndpoint=true <<<  (OUT), Pattern:InOut, Properties:{CamelToEndpoint=http://openscout.ou.nl:8080/OpenScout_Competence_Webservices/CompetenceServicesService?throwExceptionOnFailure=false&bridgeEndpoint=true, CamelCharsetName="utf-8", CamelSkipGzipEncoding=true}, Headers:{SOAPAction=, X-Powered-By=Servlet/2.5, CamelHttpMethod=POST, Server=Sun Java System Application Server 9.1_02, Content-Type=text/xml;charset="utf-8", CamelHttpUri=http://localhost:8080/rest/competences, Date=Tue, 05 Apr 2011 13:42:52 GMT, org.restlet.http.version=HTTP/1.1, org.restlet.startTime=1302011012673, CamelHttpResponseCode=200, service=competences, Transfer-Encoding=chunked, org.restlet.http.headers=[Host: localhost:8080, User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0, Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8, Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3, Accept-Encoding: gzip, deflate, Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep-alive]}, BodyType:String, Body: http://openscout.ou.nl:8080/OpenScout_Competence_Webservices/CompetenceServicesService?throwExceptionOnFailure=false&bridgeEndpoint=true <<<  (OUT), Pattern:InOut, Properties:{CamelToEndpoint=http://openscout.ou.nl:8080/OpenScout_Competence_Webservices/CompetenceServicesService?throwExceptionOnFailure=false&bridgeEndpoint=true, CamelSkipGzipEncoding=true, CamelCharsetName="utf-8"}, Headers:{CamelHttpUri=http://localhost:8080/rest/competences, org.restlet.http.headers=[Host: localhost:8080, User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0, Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8, Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3, Accept-Encoding: gzip, deflate, Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep-alive], SOAPAction=, CamelHttpMethod=POST, Content-Type=text/xml;charset=UTF-8, org.restlet.startTime=1302011012673, service=competences, org.restlet.http.version=HTTP/1.1}, BodyType:String, Body: http://openscout.ou.nl:8080/OpenScout_Competence_Webservices/CompetenceServicesService?throwExceptionOnFailure=false&bridgeEndpoint=true <<<  (OUT), Pattern:InOut, Properties:{CamelToEndpoint=http://openscout.ou.nl:8080/OpenScout_Competence_Webservices/CompetenceServicesService?throwExceptionOnFailure=false&bridgeEndpoint=true, CamelSkipGzipEncoding=true, CamelCharsetName="utf-8"}, Headers:{CamelHttpUri=http://localhost:8080/rest/competences, org.restlet.http.headers=[Host: localhost:8080, User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0, Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8, Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3, Accept-Encoding: gzip, deflate, Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep-alive], SOAPAction=, CamelHttpMethod=POST, Content-Type=text/xml;charset=UTF-8, org.restlet.startTime=1302011012673, service=competences, org.restlet.http.version=HTTP/1.1}, BodyType:String, Body:, OutBodyType:org.apache.camel.converter.stream.InputStreamCache, OutBody:org.apache.camel.converter.stream.InputStreamCache@1df6877

                    • 7. Re: Body empty?
                      Willem Jiang Master

                      Hi

                      There is an input stream in the out message body.

                      How did you get the body ? I can't tell from your camel route.

                       

                      OutBodyType:org.apache.camel.converter.stream.InputStreamCache, OutBody:org.apache.camel.converter.stream.InputStreamCache@1df6877
                      

                       

                      Willem