To use @OneWay you must have a void return type and no exceptions.
The meaning of @OneWay is that there will never be any response
from the operation and the client does not need to wait for the
operation to complete.  If there is a non-void return type or any
declared exceptions then there will be (or may be) a response
from the operation, so you cannot use @OneWay.  SCA does not
permit these responses being thrown away without being delivered
back to the caller.

I tried using @OneWay on a method with a String return type and I
got a NullPointerException, like this:
 Exception in thread "Axis2 Task" java.lang.NullPointerException
         at 
org.apache.axis2.description.OutInAxisOperationClient$NonBlockingInvo
 cationWorker.run(OutInAxisOperation.java:444)
         at 
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Wor
 ker.runTask(ThreadPoolExecutor.java:665)
         at 
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Wor
 ker.run(ThreadPoolExecutor.java:690)
         at java.lang.Thread.run(Thread.java:595)

This is a bug!  We should produce a better exception to tell the user
what he/she has done wrong.  I opened TUSCANY-1867 for this.

I am not quite sure what you are trying to accomplish by using @OneWay
with a String return type.  Do you want the response to be thrown away
and the client to continue execution in parallel with the service method?
If so, you could achieve this by creating a "wrapper" method on the
client-side service with void return type and @OneWay.  This wrapper
method would call the two-way remote method.

I modified the simple-callback-ws code to show how this could be done.
MyClient.someMethodOneWay() is the wrapper method for MyService.someMethod().
Here's the new code in MyClientImpl.java:

@Service(MyClient.class)
@Scope("COMPOSITE")
public class MyClientImpl implements MyClient, MyServiceCallback {

    private MyService myService;
    static String result;
    private MyClient myClient;
    private RequestContext context;

    @Context
    protected void setContext(RequestContext context) {
        this.context = context;
        myClient = (MyClient)context.getServiceReference().getService();
    }

    @Reference
    public void setMyService(MyService myService) {
        this.myService = myService;
    }

    public void someMethodOneWay(String arg) {
        myService.someMethod(arg);
    }

    public void aClientMethod() {
        System.out.println("aClientMethod on thread " + Thread.currentThread());
        myClient.someMethodOneWay(" -> someMethod ");
        System.out.println("aClientMethod return from someMethod on thread " + 
Thread.currentThread());
    }

    public void receiveResult(String result) {
        System.out.println("receiveResult on thread " + Thread.currentThread());
        System.out.println("Result: " + result);
        MyClientImpl.result = result;
    }
}

and in MyClient.java:

public interface MyClient {
    void aClientMethod();

    @OneWay
    void someMethodOneWay(String arg);
}

and in MyService.java:

@Remotable
@Callback(MyServiceCallback.class)
public interface MyService {

    String someMethod(String arg);
}

  Simon

Nishant Joshi wrote:

Hi, I am also trying to execute callback service with latest Tuscany code
and have modified simple-callback example with Tuscany sample. I m using
@Callback and @OneWay together, @OneWay is use with void type only than what
is with other return type values method ?
I have just tried to put @OneWay with "String getAddress(String name)"
method but it was returning me null value.
I have mainly one question,

If my callback service is returning a value(say String) and i want to work
it like @OneWay, what should i do?





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to