1 2 3 Previous Next 30 Replies Latest reply on May 3, 2010 11:51 AM by fsalceda

    Camel Router to a Web Service (InOut)

    awhelan

      Hello All.

       

      Basically what I have working is simply a service engine endpoint that exposes a web service:

       

           

       

      I need to stick a camel router in between so that when calling it from a client

      I can route the incoming call to the web service service engine (customerServiceSE)

      end point but also route that same input off to other places. I want the web service

      call to return output also (InOut).

       

      I'm stuck as to how I do this, being a Fuse newby and all.

       

      Basically I want the RouteBuilder DSL to do something like

       

         public void configure() {

                   from("binding component interface").to("service engine web service endpoint")

                                 .to("somewhere else-a file, another web service, what ever");

          }

      I'm not really sure how to go about doing this. Is there a way to

      add a router to the binding component? Does this even make sense?

        I am using Fuse 4.2 and just deploying

      the service engine and binding component as OSGI bundles. Any suggestions or help would be

      appreciated.

        • 1. Re: Camel Router to a Web Service (InOut)
          ffang

          Hi,

           

          Yeah, you can do it with deploying DSL in servicemix-caml component, which support using JBI in camel, take a look at , and more importantly, Using JBI in Camel[2]

           

           

          http://servicemix.apache.org/servicemix-camel.html

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

           

          Freeman

          • 2. Re: Camel Router to a Web Service (InOut)
            awhelan

            Thanks freeman.

             

            I've got the binding component and service engine installed as OSGI bundles with no service assembly involved.

             

            Does it make sense to do this (JBI Camel) with ServiceMix installing it as an OSGI bundle? Thats kind of where I'm crashing.

             

            thanks

            -Andy

            • 3. Re: Camel Router to a Web Service (InOut)
              awhelan

              I guess my question would be better stated by asking if it is common

              to call jbi endpoints from within components deployed as OSGI bundles like this? Does it matter(not using a service assembly)?

               

              from("jbi:endpoint:http://foo.bar.org/MyService/MyEndpoint")

               

              thanks

              -Andy

              • 4. Re: Camel Router to a Web Service (InOut)
                ffang

                Hi,

                 

                Yeah, it's ok to call jbi endpoints from bundle.

                 

                Freeman

                • 5. Re: Camel Router to a Web Service (InOut)
                  awhelan

                  I got something work with the JBI stuff to a point but I'm still crashing on something.

                   

                  I have the following configuration:

                       <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
                       
                       <camel:jmxAgent id="agent" disabled="true"></camel:jmxAgent>
                            <camel:routeBuilder ref="fileRoute"></camel:routeBuilder>
                       </camel:camelContext>
                  
                  
                       <bean id="fileRoute"
                            class="com.srcinc.purchase_order.router.PurchaseOrderRouter">
                            <property name="toUri" value="file:C:/EW/webinar/outgoing"></property>
                       </bean>
                  

                   

                  And the following DSL:

                      public void configure() {
                            LOG.info("PurchaseOrderRouter configure");
                      
                            
                            from("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint")
                            .convertBodyTo(String.class)
                            .to(toUri);
                            
                      }
                  

                  The "from" clause here contains a legitimate request-reply web service endpoint.

                  It properly takes the body of the message, converts it to a string and sends it where

                  I want but the original web service call gets hijacked and doesn't complete. I want

                  the original web service call to go on its way and complete, I just want to be able to

                  capture the message contents as it passes through and do something else with that as well

                  {the .to(toUri) portion}. Is there an easy way to do this without generating and calling

                  proxy code here?

                   

                  Edited by: awhelan on Mar 23, 2010 4:13 PM

                   

                  Edited by: awhelan on Mar 23, 2010 4:17 PM

                  • 6. Re: Camel Router to a Web Service (InOut)
                    njiang

                    Basically, you can use camel-jetty and camel-http to set up a http proxy in camel, then you can do what you want to do with the request and response message. I just assume the WebService can be access from the jbi endpoint that you showed to us in my example.

                    <camel:camelContext xmlns="http://camel.apache.org/schema/spring">Ω
                        <route>     
                            <from uri="jetty://http://YourProxyServicesAddress"></from>
                            <to uri="file:C:/EW/webinar/outgoing"></to>
                            <!-- you can also use the camel-http endpoint here -->
                            <!-- to uri="http://TheWebServiceAddress" -->
                            <to uri="jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint"></to>
                            <to uri="file:C:/EW/webinar/incomming"></to>
                        </route>
                    </camel:camelContext>
                    

                     

                    • 7. Re: Camel Router to a Web Service (InOut)
                      awhelan

                      The camel-jetty thing didn't seem to help, or maybe I'm  not completely sure what to do with it. I did however find out the following. When I do the following with my router

                       

                            from("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint?mep=in-out")

                            .convertBodyTo(String.class)

                            .to(toUri);

                       

                      The web service call actually completes the way I want it to but I have a different problem. The "mep=in-out" causes it to complete like I want it to but the rest of the command

                       

                      .convertBodyTo(String.class)

                            .to(toUri);

                      to have no affect. Again, my web service call is a simple request/response type call. Maybe people aren't understanding this. I am calling it with SoapUI. I am calling a method that takes an argment and returns a response back to the SoapUI client. With

                      from("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint?mep=in-out") that part is working like I want it to. What isn't working is the

                       

                      .convertBodyTo(String.class)

                            .to(toUri);

                      part. Besides just having the incoming call complete like it is I would like to be able to capture the SOAP content of the incoming call and send it somewhere else. Does anyone know what I can add to

                       

                      from("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint?mep=in-out") to make that work?

                      • 8. Re: Camel Router to a Web Service (InOut)
                        njiang

                        What kind of error do you have for the below part?

                        .convertBodyTo(String.class)
                        .to(toUri);
                        

                         

                        • 9. Re: Camel Router to a Web Service (InOut)
                          awhelan

                          Hi Willem,

                           

                          .convertBodyTo(String.class)

                          .to(toUri);

                           

                          isn't causing any errors, it's just not doing anything. It doesn't seem to have any effect when attached to

                           

                          from ("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint?mep=in-out")

                           

                           

                          My web service call simply takes some information as an argument(the request portion of the web service call) and adds it to a database. I want to be able to call my web service from a client, have it add the argument data to the database like it does, but I want to grab the SOAP request data within the Camel router and do something else with it also.

                           

                          Is there an easy way to grab the SOAP request data from

                          from ("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint?mep=in-out")
                          

                          while it's passing through using Camel, but still have the web service complete?

                           

                          The web service is implemented as a service engine, exposed through a binding component at the endpoint "jbi:endpoint:http://purchase_order.srcinc.com/customerService". The "from" statement above allows the web  service call to complete like I want but I'm looking for a way to grab the request data from the SOAP envelope also.

                           

                          I'm hoping for an easy way?

                           

                          The hard way would be something like generating client proxy code from the WSDL, and doing something like the following

                          from ("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint").Process();
                          

                          where I have to consume the request, and use the client stubs generated from  the  WSDL call the web service again in the Process implementation just to get access the request portion of the SOAP call and then return the SOAP response to the user.

                           

                          Do you have any advice? Any help is greatly appreciated.

                          thanks!

                          • 10. Re: Camel Router to a Web Service (InOut)
                            dkruitbosch

                            Hi Andy,

                             

                            If I understand correctly, you want to send a SOAP request through the ESB in order to send it of to it's original/final destination and send the same request to another destination in order to proces that "copied" request independently?

                             

                            If so why not use a wiretap in your camel route. I had a similar issue, and the wiretap (available since camel 2.x) solved it for me (at least for the requests). And if you need to "tap" the responses, there's a "onCompletion" handler in camel 2.x

                             

                            Look at this post in the camel-users mailing list and maybe it'll solve your issue

                             

                            http://old.nabble.com/Wiretap-filter-ts27527108.html#a27528824

                             

                            Regards,

                             

                            Danny

                             

                            Edited by: dkruitbosch on Apr 7, 2010 8:38 PM

                            • 11. Re: Camel wireTap router with InOut WebService
                              awhelan

                              Hi Clause

                               

                              Actually there is no other route (SMX EIP) or anything.

                               

                               

                              I have a service engine enpoint configured as follows:

                                   

                               

                              There is also a binding component to expose it to the outside world.

                               

                              The following Camel "from" acts as a consumer for the above web service.

                              from("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint?mep=in-out")

                               

                              As far as I know this is where I recieve the message.

                              If I add .ConvertBody(String.class).to("file:C:/out.txt") to the  above from  clause it writes the web service input to the the file C:/out.txt. The web service never completes though.

                               

                              I want to wiretap it so it writes the file out as it does above

                              but I'd like the web service to complete.

                               

                              For the following:

                              from("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint?mep=in-out").wireTap("file:C:/out.txt");

                               

                              The web service is consumed, the call actually completes, returning its output to the client but the file C:\out.txt is not created.

                               

                              Any ideas on what I'm missing? Do I really need some other route (SMX EIP???) in order to acomplish this?

                              • 12. Re: Camel Router to a Web Service (InOut)
                                awhelan

                                Sorry Danny and other members. I actually have two similar threads going. I decided the Mediator forum was probably more appropriate for wiretap questions so decided to try my luck there. When trying to respond to responses on that I accidently pasted it into this thread.

                                 

                                Actually, thanks Danny. I think the wiretap is exactly what I need.

                                 

                                I'm just trying to figure out how to get the following:

                                 

                                from("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint?mep=in-out").wireTap("file:C/out.txt");

                                 

                                actually writing out.txt. The from clause is successfully consuming the web service and returning a response to the client, but the web service request isn't being written to C:\out.txt. Any tips or things to try will be appreciated.

                                -Andy

                                • 13. Re: Camel Router to a Web Service (InOut)
                                  davsclaus

                                  Looks like you file path is wrong. You need C:/out. And maybe also try without a C letter, but just: /out

                                  • 14. Re: Camel Router to a Web Service (InOut)
                                    awhelan

                                    Hi Clause,

                                     

                                    The file path text was just a typo. It still doesn't work. Let me run something else past yah's though.

                                     

                                    If I have the "?mep=in-out" at the end of the endpoint in the from clause, the web service completes, but the wiretap doesn't work (no file is written).

                                     

                                    from("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint?mep=in-out")

                                              .wireTap("file:C:/EW/webinar/customer/soap/?fileName=report.txt")

                                              ;

                                     

                                    If on the other hand I remove the "?mep=in-out" from the end of the endpoint in the from statement, the web service doesn't complete but the request is writtten to the file (half of what I want).

                                     

                                    from("jbi:endpoint:http://purchase_order.srcinc.com/customerService/endpoint")

                                              .wireTap("file:C:/EW/webinar/customer/soap/?fileName=report.txt")

                                              ;

                                    Does this ring any bells? Again, I want the web service to complete and I want the file written to.

                                    Thanks

                                    1 2 3 Previous Next