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

Data from Apex callout doesnt work in VF Page with Standard Controller

I have a visual force page that gets data from a webservice through Apex callout. I want to display that in  the Account page in a section.
The page works fine if I access the page independently, it shows the below error if I embed the visualforce page in the Account Page Layout.

Content cannot be displayed: Web service callout failed: Unexpected element. Parser was expecting element '' but found ''

Anybody else faced this issue? What could be the fix?

NehalNehal (Salesforce Developers) 

This error usually occurs if there is some issue in communication with the external webservice.

Check the following:

1. Check if external webservice is really available and working.
2. Check if Salesforce's IP addresses are included in whitelist in the firewall of the network where the external wabservice is located.
3. Validate the endpoint address of the webservice.
4. Check if the endpoint's server is enabled as a Remote Site in Salesforce.
5. Remember that web service must be accesible from Internet to a public and valid IP address.

I hope this helps. Please mark this as a ""Best Answer"" if this has resolved your issue.
Mahsa KMahsa K
I am getting the same error:
Web service callout failed: Unexpected element. Parser was expecting element '' but found ''
The problem is that a send email button on one of our VF pages works perfectely well for some users while some other users get this error:

Web service callout failed: Unexpected element. Parser was expecting element '' but found ''
Error is in expression '{!checkSend}' in component <apex:page> in page emailconfirmation

The code that the error is refering too is:

System.debug('SendPDFByEmail - accId = ' + accId + ' contactEmail = ' + contactEmail + ' attach.Id = ' + attach.Id + ' subject = ' + subject + ' = ' + + ' companyName = ' + companyName+ + ' IsTest? = ' + test.isRunningTest());
            String retUrl = ApexPages.currentPage().getParameters().get('retUrl');
            if(retUrl != null && retUrl != '') {
                PageReference pageRef = new PageReference(retUrl);
                return pageRef;
            } else {
              string additionalParameter = '';
                additionalParameter = '&range='+ApexPages.currentPage().getParameters().get('range');
                additionalParameter += '&start='+ApexPages.currentPage().getParameters().get('start');
                additionalParameter += '&end='+ApexPages.currentPage().getParameters().get('end');
                PageReference pageRef = new PageReference('/apex/CP_ManageMyAccount?id=' +accId +'&accid=' +accId +'&printmode=pdf'+mode+additionalParameter);
                return pageRef;

I tried changing those users profiles to the ones that are working but I still get the same error. Those users have access to the email templates used in the code. Does anyone know what could have caused this? Ant help would be appreciated.