+ Start a Discussion
HaagenHaagen 

Web service callout failed: Failed to get next element

Hi,

 

In our instance we have a couple of classes generated by wsdl2apex that "randomly" (I cannot see a pattern) throws a System.CalloutException with the message "Failed to get next element". I have googled a bit but couldn't find anything that I could think was related. The web services called logs all attempts but when I get this exception I can't see that the web services has been accessed at all. The web services are all build with .NET 3. 

 

I don't know what the best way to start troubleshoot this is. So I thought I should give the boards a try!

 

Any suggestions or ideas are welcome!

 

Thanks!

 

Martin

 

 

Afzal MohammadAfzal Mohammad

Check whether your request is being sent over correctly to the end point. The best way to check your request payload is to use www.postbin.org.

 

  1. Make your post bin.
  2. Point your apex code to send the http request to your post bin url.
  3. Go to your post bin url and check the request you've sent over from apex.

However, it is also possible to get this error if your web service is not reachable from sfdc. May be its down or something.

 

Hope that helps.

 

Afzal

Afzal MohammadAfzal Mohammad

You may post your http request to postbin like this:

 

 

HttpRequest req = new HttpRequest();
// to to postbin.org and create your own debug hook
req.setEndpoint('http://www.postbin.org/YOUR_DEBUG_HOOK');
req.setMethod('POST');
req.setBody(String.valueOf(opportunityRequest));
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());

 

Hope that helps.

 

Afzal

 

HaagenHaagen

Hi Afzal,

 

and thanks for your reply. I see this error only sporadically - most, 99.9%, of all calls work just fine. Using postbin would probably not help me since I cannot replicate it. Postbin seems like a nice tool and will probably be very useful in the future while debuging callout issues from SFDC. 

 

However, you mentioned Read Time, which is another problem I see from time to time. My guess is that this "Failed to get next element" is a variation of the Read Time out exception. The plan is to modify our web services so that they will be quicker and not cause Read Time outs, maybe the "Failed to get next element" issue will dissapear in the same time.

 

Cheers!

 

Martin 

Afzal MohammadAfzal Mohammad

Were you able to resolve the issue?

 

Afzal

Elson da Costa SilvaElson da Costa Silva
Hi Haagen, 

I'm having the same problem presented by you. I see this error sporadically - most, 99.9%, of all calls work fine. Were you able to solve the problem? Did modifying web services work well? Could you help me with the solution?

Thanks!

Elson