axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Santoso Nugroho <santos...@gmail.com>
Subject Re: How to call the given replyto address from the service?
Date Thu, 24 Aug 2006 03:30:50 GMT
Hi Michele,

I've change the return type, however the callback is still not called.
Here is my service code :
public OMElement requestData(OMElement element) {
        OMElement result = buildResponse(element);
        return result;
}

Here is my client code :
OMElement payload = getPayload();
        Options options = new Options();
        options.setAction("requestData");
        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
        options.setUseSeparateListener(true);
        EndpointReference epr = new 
EndpointReference("http://localhost:8081/axis2/services/AsynchWrappedService");
        options.setTo(epr);
       
        Callback callback = new Callback() {
            public void onComplete(AsyncResult arg0) {
                System.out.println("completed, result = 
"+arg0.getResponseEnvelope());
            }

            public void onError(Exception arg0) {
                arg0.printStackTrace();
            }
           
        };
       
        ServiceClient serviceClient = null;
        try {
            ConfigurationContext configContext =         
ConfigurationContextFactory.createConfigurationContextFromFileSystem("c:\\MyJavaStuff\\axis2",

null);
            serviceClient = new ServiceClient(configContext,null);
            serviceClient.engageModule(new 
QName(Constants.MODULE_ADDRESSING));
            serviceClient.setOptions(options);
            serviceClient.sendReceiveNonBlocking(payload, callback);
           
            while(!callback.isComplete()) {
                Thread.sleep(1000);
            }
           
        } catch (AxisFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                serviceClient.finalizeInvoke();
            } catch (AxisFault e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

What is wrong with my code?

Thanks

Santoso


Michele Mazzucco wrote:
> Hi Santoso,
>
>
> I thinks you are making a mistake: asynchronous does not mean that the
> return type is void!, it means that the client does not block while the
> request is processed.
> The return type should then be OMElement, and the callback object will
> collect the result when this will be available.
>
> Regards,
> Michele
>
> Santoso Nugroho wrote:
>   
>> Hi all,
>>
>> I have an asynch service, which as I understand the operation method
>> signature returns void.
>> e.g. public void requestData(OMElement element) { ... }
>>
>> On the client side, I call the service using
>> ServiceClient.sendReceiveNonBlocking(payload, callback)
>> and I also engage the Addressing module.
>>
>> My question is, when requestData is processed, what is the code to
>> return the result to the client's callback?
>> Is it the same code as a client calling a service?
>> fyi, I already have the ReplyTo address and the MessageID (from
>> MessageContext).
>>
>>
>> Thanks a lot,
>>
>> Santoso
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>   


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


Mime
View raw message