3 Replies Latest reply on Dec 11, 2012 4:40 PM by kcbabo

    Service Method Overloading

    edevera

      Hello,

       

      I would like to know if it is possible to have method overloading on a Service and to have the ESB intelligently know which method to call based on the body of the message.

       

      So imagine:

       

      class A {...}

       

      class B {...}

       

      class Service {

       

           operation(A a) {...}

       

           operation(B b) {...}

      }

       

      Having a JMS Camel binding reading for a queue were JMS Object messages containing either instances of A or B as their body are written into and calling one method or the other dependending on the message body payload.

        • 1. Re: Service Method Overloading
          kcbabo

          No, operation names need to be unique in your service interface.  Operation overloading is prohibited by WS-I Basic Profile as well:

           

          http://ws-i.org/profiles/basicprofile-1.2-2010-11-09.html#Distinctive_Operations

           

          cheers,

          keith

          • 2. Re: Service Method Overloading
            mashama

            Hi Keith,

             

            Would it not be possible for the operation names to represented as "operationA" and "operationB" or perhaps "operation(A)" and "operation(B)" within the SwicthYard context? 

             

            Regards,

            Mashama

            • 3. Re: Service Method Overloading
              kcbabo

              Hey Mashama,

               

              The main reason we do this is for consistency across all interface types.  Each of the interface types we support reduce down to the same generic metadata model which includes a list of operations keyed by operation name.  While it's true that we could generate a unique name from a source interface like a Java class with overloaded methods, my gut tells me that this will lead to confusion down the road.  Ideally, the operation name will clearly communicate the function of the service operation and operations which take different message types will clearly reflect that.

               

              regards,

              keith