8 Replies Latest reply on Aug 11, 2009 1:26 AM by khaliqgaffar

    HOW TO REPLY BACK TO WEBSERVICE INCOMING CALL

    khaliqgaffar

      Hi ,

       

      I have created an eip diagram where incoming request comes via webservice which does certain buisness logic returns the output back to webservice.

       

      I would like to know is there any palletes or property where outcome of business logic is returned back to the webservice call ?

       

      Any help in this regard would be highly appreciated.

       

      Regards,

      Khaliq

        • 1. Re: HOW TO REPLY BACK TO WEBSERVICE INCOMING CALL
          mahesh_maheshs

          Hi,

           

          If you use CXF endpoint as the first service in your eip diagram. The route is exposed as a webservice. The wsdl is accessed by "?wsdl" after running the eip.

           

          The CXF component replies with the MessageExchange's  OUT (if set otherwise nothing will be returned to the invoker).

           

          So please keep the Message Exchange's OUT with the relevant response content. If OUT is not from anywhere in the route, you can use a bean to set it.

           

          regards,

          Mahesh

          • 2. Re: HOW TO REPLY BACK TO WEBSERVICE INCOMING CALL
            khaliqgaffar

            Hi Mahesh,

             

            I don't have any issue with plain web service where there is input and output.Issues comes when there is a intermediate process which dumps some values to queues.In this case the client calling the web service waits for infinite time eventually times out.

             

            PFA, camel xml for the same eip diagram

             

            Regards,

            Khaliq

            • 3. Re: HOW TO REPLY BACK TO WEBSERVICE INCOMING CALL
              mahesh_maheshs

              I thought of this but didn't want to piggy bag all the information in to one response.

               

              Problem explanation:

              When CXF is used as first endpoint the message exchange pattern is set to REQUEST-REPLY on the message. The same message reaches the JMS endpoint. Now JMS endpoint tries to fetch response from the receiver using JMS ReplyTo mechanism. So JMS makes the route to wait. In the mean time the HTTP connection times out. So the clients receive error response.

               

              One possible solution:

              You can implement the route as follows:

              CXF->Bean(setIN_ONLY)->JMS->Bean2(set INOUT)

               

              Bean class has 2 methods

              setInonly(Exchange ex) - sets the MEP to Inonly on ex.

              setInOut(Exchange ex) - sets the MEP to Inout on ex.

               

              This sends message to JMS destination and returns response to the client.

              • 4. Re: HOW TO REPLY BACK TO WEBSERVICE INCOMING CALL
                khaliqgaffar

                Hi Mahesh,

                 

                Can you tell me how to set in and out messages in bean within eip ? I dont see any property which defines this ?

                 

                Please let me know if this can be accomplished via FID?

                 

                I have attached something which i had based on your recommendation. Please let me know if this is the right way to do?

                 

                 

                 

                Regards,

                Khaliq

                • 5. Re: HOW TO REPLY BACK TO WEBSERVICE INCOMING CALL
                  mahesh_maheshs

                  Yup this is right have your bean to define like this:

                   

                  CXF ->Bean (setPattern2InOnly) -> JMS -> Bean(setPattern2InOut);

                   

                  Where 'Bean' = "ExchangeHelper.java"

                   

                  -


                  ExchangeHelper.java

                  -


                   

                  import org.apache.camel.Exchange;

                  import org.apache.camel.ExchangePattern;

                   

                  public class ExchangeHelper {

                   

                  public void setPattern2InOnly(Exchange exchange) {

                            ExchangePattern inOnly = ExchangePattern.InOnly;+

                            setPattern(exchange, inOnly);

                       }

                   

                   

                       public void setPattern2InOut(Exchange exchange) {

                            setPattern(exchange, ExchangePattern.InOut);

                       }

                   

                       private void setPattern(Exchange exchange, ExchangePattern pattern) {

                            exchange.setPattern(pattern);

                       }

                   

                  }

                   

                  Edited by: mahesh on Aug 10, 2009 2:16 PM

                  • 6. Re: HOW TO REPLY BACK TO WEBSERVICE INCOMING CALL
                    davsclaus

                    The latest releases of Camel have DSL for changing the MEP

                     

                    from(webservice)

                    .inOnly()

                    .to(jms)

                    .inOut()

                    .bean(set some response for the webservice)

                    • 7. Re: HOW TO REPLY BACK TO WEBSERVICE INCOMING CALL
                      khaliqgaffar

                      Mahesh,

                       

                      Your solution which you provided worked like charm. Thanks for your support.

                       

                      Regards,

                      Khaliq

                      • 8. Re: HOW TO REPLY BACK TO WEBSERVICE INCOMING CALL
                        khaliqgaffar

                        Please see the last post by mahesh for correct answer