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 Dave Hoffer <DH...@xrite.com> on 2006/05/30 19:59:28 UTC

[Axis2] How to design a Java API that is both Java and web-service friendly?

I have some POJO classes that I am designing were I will have both Java
clients (using the classes directly thru jar) as well as clients
accessing the code through a web-service API (the primary web-service
client will be JavaScript/IE).  Ideally (not required), I would like
both API's to be the same.  Here is the proposed Java API:

public class Driver implements ISpotMeasurement
{
    /**
     * This initiates the process of measuring and registers a listener
for the measurement results.
     *
     * @param listener
     */
    public void addSpotMeasurementListener(ISpotMeasurementListener
listener)
    {
    }

    /**
     * This terminates the process of measuring and removes the
registered listener.
     *
     * @param listener
     */
    public void removeSpotMeasurementListener(ISpotMeasurementListener
listener)
    {
    }

    /**
     * Enable the instrument to take a measurement now.  The actual
measurement may be delayed until the
     * user performs the physical measurement, in the case of
instruments with shoe activated measurement.
     */
    public void beginSpotMeasurement()
    {
    }
}

public interface ISpotMeasurementListener
{
    public void onSpotMeasurement( double[] data, int statusCode );
}

The client calls beginSpotMeasurement() asynchronously and the data is
returned via the listener.  This makes sense in the case of the Java
application but can Axis2 & web-services make this sort of an API?  Can
a web-service API register listeners?  I definitely need state
maintained on the server which I understand Axis2 supports; however is
there a better way to implement this API for the web-service clients?
What about JavaScript?  What client proxies are available?  

I understand, as newbie, that Axis2 can generate synchronous and
asynchronous method calls; how does this work given this API, given the
JavaScript client?

Thanks,

-dh

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [Axis2] How to design a Java API that is both Java and web-service friendly?

Posted by robert lazarski <ro...@gmail.com>.
I'll try and answer your questions to a point where you can start moving
torwards a solution. Some of these I haven't tried yet but I know they
exist:

1) For an axis2 Javascript service, take a look here:

http://issues.apache.org/jira/browse/AXIS2-625?page=all

2) For registering a listener, using JMS as the transport might be what
you're after though I haven't used axis2 with JMS. Axis2 supports JMS, and
while I didn't find any docs where I thought they would be, there are unit
tests in the source such as JMSEchoRawXMLTest . Dims may be able to comment
more.

3) I typically use an adapter or a Spring service that sits in between the
axis2 / web layer invokations to the business layer that provides the same
glue between the layers.

4) WS-Addressing generates an UUID that can be used for session tracking,
along with ServiceGroupContext. I often either generate a UUID and store it
via EHCache, or use a stateful session bean to generate and expire an ID for
me - but I'm strange like that ;-) .

HTH,
Robert
http://www.braziloutsource.com/


On 5/30/06, Dave Hoffer <DH...@xrite.com> wrote:
>
> I have some POJO classes that I am designing were I will have both Java
> clients (using the classes directly thru jar) as well as clients
> accessing the code through a web-service API (the primary web-service
> client will be JavaScript/IE).  Ideally (not required), I would like
> both API's to be the same.  Here is the proposed Java API:
>
> public class Driver implements ISpotMeasurement
> {
>     /**
>      * This initiates the process of measuring and registers a listener
> for the measurement results.
>      *
>      * @param listener
>      */
>     public void addSpotMeasurementListener(ISpotMeasurementListener
> listener)
>     {
>     }
>
>     /**
>      * This terminates the process of measuring and removes the
> registered listener.
>      *
>      * @param listener
>      */
>     public void removeSpotMeasurementListener(ISpotMeasurementListener
> listener)
>     {
>     }
>
>     /**
>      * Enable the instrument to take a measurement now.  The actual
> measurement may be delayed until the
>      * user performs the physical measurement, in the case of
> instruments with shoe activated measurement.
>      */
>     public void beginSpotMeasurement()
>     {
>     }
> }
>
> public interface ISpotMeasurementListener
> {
>     public void onSpotMeasurement( double[] data, int statusCode );
> }
>
> The client calls beginSpotMeasurement() asynchronously and the data is
> returned via the listener.  This makes sense in the case of the Java
> application but can Axis2 & web-services make this sort of an API?  Can
> a web-service API register listeners?  I definitely need state
> maintained on the server which I understand Axis2 supports; however is
> there a better way to implement this API for the web-service clients?
> What about JavaScript?  What client proxies are available?
>
> I understand, as newbie, that Axis2 can generate synchronous and
> asynchronous method calls; how does this work given this API, given the
> JavaScript client?
>
> Thanks,
>
> -dh
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>