10 Replies Latest reply on Sep 18, 2010 8:51 AM by rubrick

    Dynamic service endpoints

    david_b

      Hi, I'm very much new to jBoss ESB but finding it useful so far. I have a bit of a challenging problem and I'm hoping for some help. Even just a pointer to the correct section of the documentation would be enough at this stage.

       

      I have a number of webservices that can provide real-time data, and a client application that can query a single service.

       

      I've made these services accessible through the ESB using the SOAPProxy action to de-couple the client from the endpoints. I've also managed to aggregate the results from multiple services. This is great, although everything I've done to date requires the service endpoint addresses be pre-confgured in the ESB.

       

      The environment I'm working in is fairly dynamic so I'm looking for something more flexible. Service endpoint addresses will change regularly and the services can join and leave at arbitrary times.

       

      What I'm looking for is a way for a service to register with the ESB when the service comes online. When a client requests information from the ESB I would like it to query all instances of the service that are active at that time, aggregate the results and return them to the client.

       

      Is something like this possible in jBoss ESB?

       

      Any assistance would be greatly appreciated.

        • 1. Re: Dynamic service endpoints
          noelo

          One solution which comes to mind is to register the data service in the UDDI under a specific category. Then write a custom action to query the UDDI to get all the associated services for this category and invoke the services one by one.

          • 2. Re: Dynamic service endpoints
            h.wolffenbuttel

            The JBoss ESB is build to handle many messages. To have a dynamic configuration means you have to spend time to determine wich services must be loaded, then they must be loaded before being able to process the message. I think that for this reason you have to have a configuration ready at deployment time. This means all services will have to be configured in advance. Every new addition to the ESB means a new deployment of the new configuration. This means for your sollution you have to add more and more services (and delete the ones that are no longer active). If you have the WSDL locally you don't have to worry about the service you proxy to be online, if not you do. SoapProxy will prevent the service from starting when the remote service is not online and it depends on it's wsdl.

             

            Calling each service is possible with the ServiceInvoker within the custom action described by Noel.

            • 3. Re: Dynamic service endpoints
              david_b

              Thanks for the useful information. Using the ServiceInvoker in a custom action sounds like the way to go.

               

              Adding/Removing services from the UDDI will be more flexible than re-deploying a configuration each time there is a change.

              • 4. Re: Dynamic service endpoints
                izgur

                I have a number of webservices that can provide real-time data, and a client application that can query a single service.

                I've made these services accessible through the ESB using the SOAPProxy action to de-couple the client from the endpoints

                 

                Hello!

                 

                Can you please tell me HOW YOU DID THAT ? With SOAPProxy ?

                 

                BR, Igor!

                • 5. Re: Dynamic service endpoints
                  david_b
                  Igor JStarter wrote:

                   

                  Can you please tell me HOW YOU DID THAT ? With SOAPProxy ?

                   

                  You can use a http-gateway listener to receive the incoming SOAP requests, then have a single action using the inbuilt SOAPProxy class to proxy the message. My jboss-esb.xml file looks similar to this:

                   

                  jboss-esb.xml

                   

                  {code}<?xml version="1.0" encoding="UTF-8"?>
                  <jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.2.0.xsd" parameterReloadSecs="5">
                  <services>
                    <service category="MyCatagory" name="MyService"
                       description="MyServiceProxy"
                       invmScope="GLOBAL">
                     <listeners>
                      <http-gateway name="MyService-GwListener" />
                     </listeners>
                     <actions mep="RequestResponse">
                      <action name="proxy"
                        class="org.jboss.soa.esb.actions.soap.proxy.SOAPProxy">
                        <property name="wsdl" value="http://localhost:1234/MyService/Service.asmx?WSDL"/>
                      </action>
                     </actions>
                    </service>
                  </services>
                  </jbossesb>{code}

                   

                  The wsdl property points to the external webservice WSDL.

                   

                  Deploy this to the ESB and it will create it's own version of the external service using the WSDL provided. Your client can then access the webservice through the ESB. Assuming the ESB is running on localhost, the endpoint for the service will look something like http://localhost:8080/MyServiceProxy/http/MyCatagory/MyService

                   

                  You can examine all the ESB provided webservices by visiting http://localhost:8080/contract/. If your service was deployed correctly you should see it listed with the new contract and endpoint URLs.

                  • 6. Re: Dynamic service endpoints
                    izgur

                    THANK YOU A LOT !!! So that's is  the first thing working on my ESB .)

                     

                    So this is the solution when :

                    - you already have a wsdl/ws somewhere exposed or if you somewhere write a new web service somewhere else and deploy it (re-use in esb).

                     

                    But can I write the service direct on the esb ?

                     

                    If we get a call of our webservice, our MyService-GWListener will catch it. But how do we get the parameters now ?

                     

                    Up to know i think about a new ESB project, where the jboss-esb.xml would look like:

                    <action name="soapui-client-action" class="org.jboss.soa.esb.actions.soap.SOAPClient">
                    <property name="wsdl" value="http://localhost:1234/MyService/Service?wsdl"/>
                    <property name="operation" value="SendNotification"/>
                    </action>

                     

                    And then somehow bind the message.getBody().get() to the SendNotification ?

                     

                    Thank you for all replies in advance!!

                     

                    BR, Igor!

                    • 7. Re: Dynamic service endpoints
                      h.wolffenbuttel

                      How do you register a new service in the UDDI without having to predefine it first?

                      • 8. Re: Dynamic service endpoints
                        david_b

                        Hans Wolffenbuttel wrote:

                         

                        How do you register a new service in the UDDI without having to predefine it first?

                         

                        I was thinking of creating an ESB service to register a new webservice i.e.

                         

                        - A new webservice provider starts up

                        - It calls the ESB service, passing it's location

                        - A custom action registers the location in the UDDI under a particular catagory.

                         

                        I'm not sure if this is a valid approach as I'm still working out how the UDDI registry is used exactly. I could be completely off track. Can I store information for external webservices in the UDDI like this?

                        • 9. Re: Dynamic service endpoints
                          h.wolffenbuttel

                          As far as I can tell is a service deployed by interpreting XML of your .esb file. So I assume you need to have a template of XML which you alter before you register your service to get it deployed, that is, if you want to use the JBossESB functionality and don't want to be bothered with tasks a JBossESB should take care of for you. I don't know a bout registering your service into UDDI, but I think you first have to think about how you get your service deployed without a predefined service.

                          • 10. Re: Dynamic service endpoints
                            rubrick

                            david_b wrote:

                             

                            ... I've also managed to aggregate the results from multiple services. ...

                             

                            I wonder how you managed to do this?

                             

                            I'm looking for something like this: I want to expose a webservice on the ESB, which expects a single request from a client, forwards the (slightly modified) request to multiple different backend webservices, aggregates the results from these backend calls and send back the combined result to the client. How would something like this be done?