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 juliocest <ju...@gmail.com> on 2008/04/17 14:25:15 UTC

SendReceive and Response Time

Dear members,

I have a doubt with regarding to give a response time from a sendReceive
call in a service client. 
My client code is presented below:

---------------------------------------------------------------------------------------------------------------------------
import java.io.File;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.OperationContext;
import org.apache.axis2.transport.http.*;

public class Client {
    public static OMElement response;
    public static OperationContext opContext = null;
    public static long t1 = 0;
    public static long t2 = 0;
    
	public static void main(String[] args) {	
    	try { 
    		  AppTime time = new AppTime();
    		  Arquivo arquivo = new Arquivo();
    		  Message soapMessage = new Message();
   		  	  Options options = new Options();   
    		  ServiceClient client = new ServiceClient();
		      EndpointReference remotob = new
EndpointReference("http://arara.sytes.net:8080/axis2/services/Avaliacao");
		      options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(360000));
		      options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
		      options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
		      options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
		      options.setProperty(HTTPConstants.MC_GZIP_RESPONSE, Boolean.TRUE);		      
   		      options.setTo(remotob);
    		      client.setOptions(options);
	  		  		  	
		      OMElement m = soapMessage.messageTeste("Teste");
		  	  
		      t1 = System.nanoTime();

    		         OMElement response = client.sendReceive(m);
    		      		   
                         System.out.println(response);

                      t2 = System.nanoTime();

                    System.out.println("Response Time =
"+Double.toString((double)(t2-t1) / 1000000000));
    		                            	    		  			                  
            } catch (Exception e) { //(XMLStreamException e) {
                System.out.println(e.toString());
            }
        }
 }   

---------------------------------------------------------------------------------------------------------------------------

I will explain what is the aim of the service. The client will send a
message to service provider. The service provider will give the message and
parser a xml file from disk. The xml parsed from disk will be sent to
client. Then the client will show the xml with came from the server.
 
My doubt is: Where I get the initial and final time in order to obtain a
response time? Why am I aksking it? 

What seems to me that Axis2 only show the response needed by the client.
Then if I get (t2) after System.out.println(response); I will have the real
response time, because I am receiving a response.  Dou you agree with me?

I would be grateful to receive a response as soon as possible.

Júlio

-- 
View this message in context: http://www.nabble.com/SendReceive-and-Response-Time-tp16743797p16743797.html
Sent from the Axis - User mailing list archive at Nabble.com.


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


Re: SendReceive and Response Time

Posted by Michele Mazzucco <Mi...@ncl.ac.uk>.
If you use sendReceive() the client thread will block until the  
response has been received.
This means that the t2 must be taken before printing the result.

Michele


On 17 Apr 2008, at 13:25, juliocest wrote:
>
> Dear members,
>
> I have a doubt with regarding to give a response time from a  
> sendReceive
> call in a service client.
> My client code is presented below:
>
> ---------------------------------------------------------------------- 
> -----------------------------------------------------
> import java.io.File;
>
> import org.apache.axiom.om.OMElement;
> import org.apache.axiom.soap.SOAPBody;
> import org.apache.axiom.soap.SOAPEnvelope;
> import org.apache.axis2.Constants;
> import org.apache.axis2.addressing.EndpointReference;
> import org.apache.axis2.client.Options;
> import org.apache.axis2.client.ServiceClient;
> import org.apache.axis2.context.OperationContext;
> import org.apache.axis2.transport.http.*;
>
> public class Client {
>     public static OMElement response;
>     public static OperationContext opContext = null;
>     public static long t1 = 0;
>     public static long t2 = 0;
>
> 	public static void main(String[] args) {	
>     	try {
>     		  AppTime time = new AppTime();
>     		  Arquivo arquivo = new Arquivo();
>     		  Message soapMessage = new Message();
>    		  	  Options options = new Options();
>     		  ServiceClient client = new ServiceClient();
> 		      EndpointReference remotob = new
> EndpointReference("http://arara.sytes.net:8080/axis2/services/ 
> Avaliacao");
> 		      options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer 
> (360000));
> 		      options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
> 		      options.setProperty(HTTPConstants.MC_GZIP_REQUEST,  
> Boolean.TRUE);
> 		      options.setProperty(HTTPConstants.MC_ACCEPT_GZIP,  
> Boolean.TRUE);
> 		      options.setProperty(HTTPConstants.MC_GZIP_RESPONSE,  
> Boolean.TRUE);		
>    		      options.setTo(remotob);
>     		      client.setOptions(options);
> 	  		  		  	
> 		      OMElement m = soapMessage.messageTeste("Teste");
> 		  	
> 		      t1 = System.nanoTime();
>
>     		         OMElement response = client.sendReceive(m);
>     		      		
>                          System.out.println(response);
>
>                       t2 = System.nanoTime();
>
>                     System.out.println("Response Time =
> "+Double.toString((double)(t2-t1) / 1000000000));
>     		                            	    		  			
>             } catch (Exception e) { //(XMLStreamException e) {
>                 System.out.println(e.toString());
>             }
>         }
>  }
>
> ---------------------------------------------------------------------- 
> -----------------------------------------------------
>
> I will explain what is the aim of the service. The client will send a
> message to service provider. The service provider will give the  
> message and
> parser a xml file from disk. The xml parsed from disk will be sent to
> client. Then the client will show the xml with came from the server.
>
> My doubt is: Where I get the initial and final time in order to  
> obtain a
> response time? Why am I aksking it?
>
> What seems to me that Axis2 only show the response needed by the  
> client.
> Then if I get (t2) after System.out.println(response); I will have  
> the real
> response time, because I am receiving a response.  Dou you agree  
> with me?
>
> I would be grateful to receive a response as soon as possible.
>
> Júlio
>
> -- 
> View this message in context: http://www.nabble.com/SendReceive-and- 
> Response-Time-tp16743797p16743797.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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