2 Replies Latest reply on Sep 27, 2009 7:47 PM by gertv

    Camel router does not send response back to service caller

    fuzzylogic

      use the following archetecture:

       

      Binding component for the webservices ->  Service Engine->Camel Router

      (hosted in fuseESB)                                                    (webservice)

       

       

      The camel router receives a message from a webservice through the normalized message router (NMR), The router does the XSLT transformation processing successfully, and we are able to read the processed xml message in the .process method, however once the process is complete we are unable to send any type of response message back the the calling service.   Can any expert provide an example on how this should be done.

       

      below is the configure() from routebuilder.java

       

      below is  also the invokecation from the calling service and the service response handler

      -


       

      public void configure() {

                from("jbi:service:http://service1.test.com/service/someRouter")      

              .convertBodyTo("javax.xml.transform.sax.SAXSource")

              .to("jbi:service:http://service1.test.com/service1/transformRequest_v1_0?mep=in-out")                    

              .to("file://c://tmp//SAMPLE_TEXT.TXT");

          }

       

       

      -


       

              public String invokeRouter(String xmlRequest)throws Exception

              {

          String response = null;

          ServiceMixClient client = createClient();

          if(client != null)

          {

              Destination destination = client.createDestination("service:http://service1.test.com/service/someRouter");

              InOut exchange = destination.createInOutExchange();

              NormalizedMessage request = exchange.getInMessage();

                      String strXML =  "" "<Person>"

                                              "";

       

               

              request.setContent(new SAXSource(new InputSource(new StringReader(xmlString))));

              client.sendSync(exchange);

              if(exchange.getError() != null)

                  throw new Exception(exchange.getError().getMessage());

              NormalizedMessage responseMsg = exchange.getOutMessage();              

       

              if(null != responseMsg)

              {

                  javax.xml.transform.Source responseContent = responseMsg.getContent();

                  response = (new SourceTransformer()).toString(responseContent);

              }

              xmlRequest = null;

          } else

          {

              response = xmlRequest;

              throw new Exception("Error invoking some Router. Could not create ServiceMixClient.");

          }

          client.close();

          return response;

      }

        • 1. Re: Camel router does not send response back to service caller
          davsclaus

          When you say response back I assume its the client code that does not receive a response?

           

          Does Camel write the file as its the last step in the camel route?

           

          You can try with something very simple in Camel to see if it can reply back

          String reply = "<xml ...."; // a xml reply here
          // then a very simple camel route to reply that constant
          from("jbi:xxx").transform(constant(reply));
          

           

          Then go from there and add to Camel one piece at a time until you do not get a reply back.

           

          And you can use the Camel tracer to help log what is going on

          Tracer

          • 2. Re: Camel router does not send response back to service caller
            gertv

            L.S.,

             

            Do you see any exceptions or error messages when you're running this example?  Is the out message content just null or does it throw an exception when you try to convert it to String?

             

            Regards,

             

            Gert