• John Dayondon
  • NEWBIE
  • 15 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies

Hi,

I'm not sure what I'm doing wrong here but even if I set the timeout to 120secs or 60secs it still throws a time out exception after 10secs.

Here's the code that makes the call out. This code is used as a OnClick Javascript on my custom button.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    req.setMethod('GET');
    req.setTimeout(120000);
    
    try
    {
      HTTPResponse response = m_http.send(req);
      
     if(response.getBody() != null)
        return 'Success';
     else
        return 'Failed'; 
            
    } catch(System.CalloutException e) {
      return 'Error ' + e;
    }
------------------------------------------------------------------------------------------------------------------------------------------------------------

Is there somewhere else I need to set to make sure it uses the timeout set on the code?

Thanks for the help.

Hi,

I trying to create a custom button on our custom object page that would call an external REST API. 
User-added image

When I tested it it gave me the "Unexpeced end of input" error.

Hi,

I'm not sure what I'm doing wrong here but even if I set the timeout to 120secs or 60secs it still throws a time out exception after 10secs.

Here's the code that makes the call out. This code is used as a OnClick Javascript on my custom button.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    req.setMethod('GET');
    req.setTimeout(120000);
    
    try
    {
      HTTPResponse response = m_http.send(req);
      
     if(response.getBody() != null)
        return 'Success';
     else
        return 'Failed'; 
            
    } catch(System.CalloutException e) {
      return 'Error ' + e;
    }
------------------------------------------------------------------------------------------------------------------------------------------------------------

Is there somewhere else I need to set to make sure it uses the timeout set on the code?

Thanks for the help.

Hi,

I trying to create a custom button on our custom object page that would call an external REST API. 
User-added image

When I tested it it gave me the "Unexpeced end of input" error.

Hi all,

 

I am having some problems setting the callout timeout in apex. I have a class generated by the WSDL2Apex tool which works fine but I can't seem to be able to change the timeout value. I have tried changing the value of the timeout__x variable that is generated but this doesn't seem to do anything, am I supposed to use this variable during my web service invokation? My code is:

 

 

//Generated by wsdl2apex

public class smsService {

public class sendsms_element {

public String[] sMobileNums;

  public String sMessage;

public String sFrom;

public String sOrganisationId;

private String[] sMobileNums_type_info = new String[]{'sMobileNums','http://www.w3.org/2001/XMLSchema','string','0','-1','true'};

private String[] sMessage_type_info = new String[]{'sMessage','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] sFrom_type_info = new String[]{'sFrom','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] sOrganisationId_type_info = new String[]{'sOrganisationId','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] apex_schema_type_info = new String[]{'http://expwsms','true','true'};

private String[] field_order_type_info = new String[]{'sMobileNums','sMessage','sFrom','sOrganisationId'};

}

 

public class receiveSMSResponse_element {

public String return_x;

private String[] return_x_type_info = new String[]{'return','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] apex_schema_type_info = new String[]{'http://expwsms','true','true'};

private String[] field_order_type_info = new String[]{'return_x'};

}

 

public class expwsmsHttpSoap11Endpoint {

public String endpoint_x = 'http://hosted.expw.com:8002/axis2/services/expwsms.expwsmsHttpSoap11Endpoint/';

public Map<String,String> inputHttpHeaders_x;

public Map<String,String> outputHttpHeaders_x;

public String clientCert_x;

public String clientCertPasswd_x;

public Integer timeout_x = 120000;

private String[] ns_map_type_info = new String[]{'http://expwsms', 'smsService'};

public String receiveSMS(String JobId,String SMSMessage,String MobileNo,String VMN,String Keyword,String AccountId,String Network,String RecievedDate) {

smsService.receiveSMS_element request_x = new smsService.receiveSMS_element();

smsService.receiveSMSResponse_element response_x;

request_x.JobId = JobId;

request_x.SMSMessage = SMSMessage;

request_x.MobileNo = MobileNo;

request_x.VMN = VMN;

request_x.Keyword = Keyword;

request_x.AccountId = AccountId;

request_x.Network = Network;

request_x.RecievedDate = RecievedDate;

Map<String, smsService.receiveSMSResponse_element> response_map_x = new Map<String, smsService.receiveSMSResponse_element>();

response_map_x.put('response_x', response_x);

WebServiceCallout.invoke(

this,

request_x,

response_map_x,

new String[]{endpoint_x,

'urn:receiveSMS',

'http://expwsms',

'receiveSMS',

'http://expwsms',

'receiveSMSResponse',

'smsService.receiveSMSResponse_element'}

);

response_x = response_map_x.get('response_x');

return response_x.return_x;

}

 

public String sendsms(String[] sMobileNums,String sMessage,String sFrom,String sOrganisationId) {

smsService.sendsms_element request_x = new smsService.sendsms_element();

smsService.sendsmsResponse_element response_x;

request_x.sMobileNums = sMobileNums;

request_x.sMessage = sMessage;

request_x.sFrom = sFrom;

request_x.sOrganisationId = sOrganisationId;

request_x.setTimeout(2000);

Map<String, smsService.sendsmsResponse_element> response_map_x = new Map<String, smsService.sendsmsResponse_element>();

response_map_x.put('response_x', response_x);

WebServiceCallout.invoke(

this,

request_x,

response_map_x,

new String[]{endpoint_x,

'urn:sendsms',

'http://expwsms',

'sendsms',

'http://expwsms',

'sendsmsResponse',

'smsService.sendsmsResponse_element'}

);

response_x = response_map_x.get('response_x');

return response_x.return_x;

}

}

 

public class sendsmsResponse_element {

public String return_x;

private String[] return_x_type_info = new String[]{'return','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] apex_schema_type_info = new String[]{'http://expwsms','true','true'};

private String[] field_order_type_info = new String[]{'return_x'};

}

 

public class receiveSMS_element {

public String JobId;

public String SMSMessage;

public String MobileNo;

public String VMN;

public String Keyword;

public String AccountId;

public String Network;

public String RecievedDate;

private String[] JobId_type_info = new String[]{'JobId','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] SMSMessage_type_info = new String[]{'SMSMessage','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] MobileNo_type_info = new String[]{'MobileNo','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] VMN_type_info = new String[]{'VMN','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] Keyword_type_info = new String[]{'Keyword','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] AccountId_type_info = new String[]{'AccountId','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] Network_type_info = new String[]{'Network','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] RecievedDate_type_info = new String[]{'RecievedDate','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

private String[] apex_schema_type_info = new String[]{'http://expwsms','true','true'};

private String[] field_order_type_info = new String[]{'JobId','SMSMessage','MobileNo','VMN','Keyword','AccountId','Network','RecievedDate'};

}

 

Please help as I have checked loads of documentation but can't seem to find out how to do this (I have tried request_x.setTimeout(120000) and request_x.timeout__x = 120000 but these don't seem to work. How can I set the timeout for this request?

 

Thanks

 

James 

Message Edited by Jamz_2010 on 10-05-2009 08:46 AM
Message Edited by Jamz_2010 on 10-05-2009 08:46 AM
Message Edited by Jamz_2010 on 10-05-2009 08:51 AM