function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MehmetMehmet 

System.CalloutException: Web service callout failed: Failed to get next element

I get this error when I try to call a webservice through a class generated from WSDL by WSDL2Apex. The strange thing is:

1. When I send the request to http://requestb.in, I can see that the request arrives properly. This is the message as seen in requestb.in:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<env:Header />
	<env:Body>
		<PingRequest xmlns="http://www.abacus.ch/abaconnect/2007.10/core/AbaConnectTypes">
			<Echo>Hello Abacus</Echo>
		</PingRequest>
	</env:Body>
</env:Envelope>
2. When I send the exact same message to the proper endpoint via SoapUI, I get a proper response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <act:PingResponse xmlns:act="http://www.abacus.ch/abaconnect/2007.10/core/AbaConnectTypes">
         <act:Echo>hello this is the AbaConnect Webservice Server! Your message was: Hello Abacus( Ping-Nr: 1)</act:Echo>
      </act:PingResponse>
   </soapenv:Body>
</soapenv:Envelope>
3. But when I use Apex to send the request, I get the error message in the log:
19:08:10.249 (249851430)|SYSTEM_METHOD_ENTRY|[1846]|WebServiceCallout.invoke(APEX_OBJECT, APEX_OBJECT, MAP, LIST)
19:08:10.253 (253470025)|CALLOUT_REQUEST|[1846]|PingType:[Echo=Hello Abacus, Echo_type_info=(Echo, http://www.abacus.ch/abaconnect/2007.10/core/AbaConnectTypes, null, 1, 1, false), apex_schema_type_info=(http://www.abacus.ch/abaconnect/2007.10/core/AbaConnectTypes, true, false), field_order_type_info=(Echo)]::SFDC_STACK_DEPTH=1 SOAPAction="ping" User-Agent=SFDC-Callout/30.0 Accept=text/xml Content-Type=text/xml; charset=UTF-8 
19:08:10.344 (344790775)|EXCEPTION_THROWN|[1846]|System.CalloutException: Web service callout failed: Failed to get next element
19:08:10.344 (344950829)|HEAP_ALLOCATE|[1846]|Bytes:58
19:08:10.344 (344974228)|SYSTEM_METHOD_EXIT|[1846]|WebServiceCallout.invoke(APEX_OBJECT, APEX_OBJECT, MAP, LIST)
I searched and googled quite a lot, but couldn't find any solution so far. Some people have the same error, but no solution suggested that would help me.

Any help will be greatly appreciated.

Cheers

Mehmet




Ramu_SFDCRamu_SFDC
See if the below posts help

https://developer.salesforce.com/forums?id=906F00000008yx5IAA
http://salesforce.stackexchange.com/questions/2146/web-service-callout-failed-error
http://salesforce.stackexchange.com/questions/22054/salesforce-callout-exception
MehmetMehmet
Hi Ramu

Thanks for your suggestions, but unfortunately none of them could help me solve this issue.

I have been in contact with the developers of the web service, and they suggested that the problem might be due to the fact that they use MTOM and Salesforce may not be able to handle this.

Does anyone know more about this topic? Any solutions or workarounds?

Thanks

Mehmet