How to set client timeout in an axis2c client

445 views Asked by At

I had a WSDL file then I used AXIS2C WSDL2C tool to create the client project.

I modified the axis2.xml file. added this line in the beginning after <axisconfig name="Axis2/C">:

<parameter name="SO_TIMEOUT">8000</parameter>

I can now set the timeout. How can I handle it in my code? I mean How can I know that I've got a connection timeout or a socket timeout or the server responded properly.

Question Update: here is a link to my project :

1

There are 1 answers

4
loentar On

You should analyze error code from env->error->status_code after you invoke the client:

axiom_node_t* resp = axis2_svc_client_send_receive(client, env, payload);

switch (env->error->status_code)
{
case AXIS2_ERROR_RESPONSE_TIMED_OUT:
  // Timeout
    break;

// other errors goes here ...
}

Also if you want to set timeout programmatically:

axis2_options_t* opt = axis2_options_create(env)
axis2_options_set_timeout_in_milli_seconds(opt, env, 8000);
axis2_svc_client_set_options(client, env, opt);