You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Chris Mannion <ch...@nonstopgov.com> on 2009/08/07 15:06:17 UTC
Writing a service with multiple operations
Hi all
I've been re-building my old Axis based web-services as Axis2 services
but am a little puzzled about one issue. Two of the services I have
make multiple operations available so I'm just wondering how I got
about building that with Axis2. All the other services that I've
managed to deploy so far all have only one operation so I've managed
to build Java classes with one method which takes an OMElement as
input without really understanding how Axis2 knows that that's the
correct method to call when the web-service is invoked. Now that
there will be multiple methods to match multiple operations on the
web-service, I really need to properly understand how Axis determines
which class method relates to which WS operation. Is it as simple as
making sure the methods have the same name as the operations or is
there something more complicated I'll need to do?
--
Chris Mannion
iCasework and LocalAlert implementation team
0208 144 4416
Re: Writing a service with multiple operations
Posted by Chris Mannion <ch...@nonstopgov.com>.
Thank you, that's exactly what I meant. So the method names,
"authenticate" and "authenticateWithRole", matching with the operation
names defined in the services.xml is enough for Axis to know which
method to invoke when a request comes in, thank you.
2009/8/7 Chinmoy Chakraborty <cc...@gmail.com>:
> Do you want to deploy service which has multiple operations? What do you
> mean by "actually building the java class that implements the service"?
>
> If you mean how to write service class with multiple operations then just
> add public methods as you did for single operation e.g. I can have two
> operations for service "AUTHENTICATE_SERVICE"
>
> public String authenticate(String username, String password)
> public String authenticateWithRole(String username, String password, String
> role)
>
> and you need to add these in your services.xml. e.g.
> ...
> <parameter name="ServiceClass">abc.service.AuthenticateService</parameter>
> <operation name="authenticate">
> <messageReceiver
> class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
> </operation>
> <operation name="authenticateWithRole">
> <messageReceiver
> class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
> </operation>
> ......
>
> Chinmoy
>
> On Fri, Aug 7, 2009 at 7:03 PM, Chris Mannion <ch...@nonstopgov.com>
> wrote:
>>
>> That would be using a client to invoke a service with mutliple
>> operations though, right? I'm talking about actually building the
>> Java class that implements the service.
>>
>> 2009/8/7 Chinmoy Chakraborty <cc...@gmail.com>:
>> > You can have multiple operations for a single service name. You just
>> > need to
>> > set the action (operation name) of a service you want to invoke.
>> >
>> > Options options = new Options();
>> > RPCServiceClient client = new RPCServiceClient();
>> > options.setTo(targetEPR);
>> > options.setAction(OPERATION_NAME);
>> > options.setTimeOutInMilliSeconds(600000);
>> > client.setOptions(options);
>> > ................
>> > and your service name should be .../service/service_name.
>> >
>> > HTH,
>> > Chinmoy
>> >
>> > On Fri, Aug 7, 2009 at 6:36 PM, Chris Mannion
>> > <ch...@nonstopgov.com>
>> > wrote:
>> >>
>> >> Hi all
>> >>
>> >> I've been re-building my old Axis based web-services as Axis2 services
>> >> but am a little puzzled about one issue. Two of the services I have
>> >> make multiple operations available so I'm just wondering how I got
>> >> about building that with Axis2. All the other services that I've
>> >> managed to deploy so far all have only one operation so I've managed
>> >> to build Java classes with one method which takes an OMElement as
>> >> input without really understanding how Axis2 knows that that's the
>> >> correct method to call when the web-service is invoked. Now that
>> >> there will be multiple methods to match multiple operations on the
>> >> web-service, I really need to properly understand how Axis determines
>> >> which class method relates to which WS operation. Is it as simple as
>> >> making sure the methods have the same name as the operations or is
>> >> there something more complicated I'll need to do?
>> >>
>> >> --
>> >> Chris Mannion
>> >> iCasework and LocalAlert implementation team
>> >> 0208 144 4416
>> >
>> >
>>
>>
>>
>> --
>> Chris Mannion
>> iCasework and LocalAlert implementation team
>> 0208 144 4416
>
>
--
Chris Mannion
iCasework and LocalAlert implementation team
0208 144 4416
Re: Writing a service with multiple operations
Posted by Chinmoy Chakraborty <cc...@gmail.com>.
Do you want to deploy service which has multiple operations? What do you
mean by "actually building the java class that implements the service"?
If you mean how to write service class with multiple operations then just
add public methods as you did for single operation e.g. I can have two
operations for service "AUTHENTICATE_SERVICE"
public String authenticate(String username, String password)
public String authenticateWithRole(String username, String password, String
role)
and you need to add these in your services.xml. e.g.
...
<parameter name="ServiceClass">abc.service.AuthenticateService</parameter>
<operation name="authenticate">
<messageReceiver
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
<operation name="authenticateWithRole">
<messageReceiver
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
......
Chinmoy
On Fri, Aug 7, 2009 at 7:03 PM, Chris Mannion
<ch...@nonstopgov.com>wrote:
> That would be using a client to invoke a service with mutliple
> operations though, right? I'm talking about actually building the
> Java class that implements the service.
>
> 2009/8/7 Chinmoy Chakraborty <cc...@gmail.com>:
> > You can have multiple operations for a single service name. You just
> need to
> > set the action (operation name) of a service you want to invoke.
> >
> > Options options = new Options();
> > RPCServiceClient client = new RPCServiceClient();
> > options.setTo(targetEPR);
> > options.setAction(OPERATION_NAME);
> > options.setTimeOutInMilliSeconds(600000);
> > client.setOptions(options);
> > ................
> > and your service name should be .../service/service_name.
> >
> > HTH,
> > Chinmoy
> >
> > On Fri, Aug 7, 2009 at 6:36 PM, Chris Mannion <
> chris.mannion@nonstopgov.com>
> > wrote:
> >>
> >> Hi all
> >>
> >> I've been re-building my old Axis based web-services as Axis2 services
> >> but am a little puzzled about one issue. Two of the services I have
> >> make multiple operations available so I'm just wondering how I got
> >> about building that with Axis2. All the other services that I've
> >> managed to deploy so far all have only one operation so I've managed
> >> to build Java classes with one method which takes an OMElement as
> >> input without really understanding how Axis2 knows that that's the
> >> correct method to call when the web-service is invoked. Now that
> >> there will be multiple methods to match multiple operations on the
> >> web-service, I really need to properly understand how Axis determines
> >> which class method relates to which WS operation. Is it as simple as
> >> making sure the methods have the same name as the operations or is
> >> there something more complicated I'll need to do?
> >>
> >> --
> >> Chris Mannion
> >> iCasework and LocalAlert implementation team
> >> 0208 144 4416
> >
> >
>
>
>
> --
> Chris Mannion
> iCasework and LocalAlert implementation team
> 0208 144 4416
>
Re: Writing a service with multiple operations
Posted by Chris Mannion <ch...@nonstopgov.com>.
That would be using a client to invoke a service with mutliple
operations though, right? I'm talking about actually building the
Java class that implements the service.
2009/8/7 Chinmoy Chakraborty <cc...@gmail.com>:
> You can have multiple operations for a single service name. You just need to
> set the action (operation name) of a service you want to invoke.
>
> Options options = new Options();
> RPCServiceClient client = new RPCServiceClient();
> options.setTo(targetEPR);
> options.setAction(OPERATION_NAME);
> options.setTimeOutInMilliSeconds(600000);
> client.setOptions(options);
> ................
> and your service name should be .../service/service_name.
>
> HTH,
> Chinmoy
>
> On Fri, Aug 7, 2009 at 6:36 PM, Chris Mannion <ch...@nonstopgov.com>
> wrote:
>>
>> Hi all
>>
>> I've been re-building my old Axis based web-services as Axis2 services
>> but am a little puzzled about one issue. Two of the services I have
>> make multiple operations available so I'm just wondering how I got
>> about building that with Axis2. All the other services that I've
>> managed to deploy so far all have only one operation so I've managed
>> to build Java classes with one method which takes an OMElement as
>> input without really understanding how Axis2 knows that that's the
>> correct method to call when the web-service is invoked. Now that
>> there will be multiple methods to match multiple operations on the
>> web-service, I really need to properly understand how Axis determines
>> which class method relates to which WS operation. Is it as simple as
>> making sure the methods have the same name as the operations or is
>> there something more complicated I'll need to do?
>>
>> --
>> Chris Mannion
>> iCasework and LocalAlert implementation team
>> 0208 144 4416
>
>
--
Chris Mannion
iCasework and LocalAlert implementation team
0208 144 4416
Re: Writing a service with multiple operations
Posted by Chinmoy Chakraborty <cc...@gmail.com>.
You can have multiple operations for a single service name. You just need to
set the action (operation name) of a service you want to invoke.
Options options = new Options();
RPCServiceClient client = new RPCServiceClient();
options.setTo(targetEPR);
options.setAction(OPERATION_NAME);
options.setTimeOutInMilliSeconds(600000);
client.setOptions(options);
................
and your service name should be .../service/service_name.
HTH,
Chinmoy
On Fri, Aug 7, 2009 at 6:36 PM, Chris Mannion
<ch...@nonstopgov.com>wrote:
> Hi all
>
> I've been re-building my old Axis based web-services as Axis2 services
> but am a little puzzled about one issue. Two of the services I have
> make multiple operations available so I'm just wondering how I got
> about building that with Axis2. All the other services that I've
> managed to deploy so far all have only one operation so I've managed
> to build Java classes with one method which takes an OMElement as
> input without really understanding how Axis2 knows that that's the
> correct method to call when the web-service is invoked. Now that
> there will be multiple methods to match multiple operations on the
> web-service, I really need to properly understand how Axis determines
> which class method relates to which WS operation. Is it as simple as
> making sure the methods have the same name as the operations or is
> there something more complicated I'll need to do?
>
> --
> Chris Mannion
> iCasework and LocalAlert implementation team
> 0208 144 4416
>