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
thienthangthienthang 

Apex SOAP Callouts - Web service callout failed

Could you guys tell me how to fix this issue? I appreciate any tip in advanced, thank you very much. I would like to describe the issue as below

I have tried the example in Trailhead for Apex SOAP Callouts.

Downloaded this xml file: https://th-apex-soap-service.herokuapp.com/assets/calculator.xml

Added this end point to remote site too: https://simple-salesforce-soap-server.herokuapp.com

But unfortuanlly, when I ran the sample code, I got this error: 
Line: 142, Column: 1
System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':html'

Follow the error log, I got this explaination: 
20:59:09:000 CALLOUT_RESPONSE               <p>There is no app configured at that hostname.<br/>Perhaps the app owner has renamed it, or you mistyped the URL.</p>

User-added image
 
SandhyaSandhya (Salesforce Developers) 
Hi,

You say that you are trying Apex SOAP call outs, but Animalscallout class is in REST call out example.And you are getting an error for Animalscallout class.

Please check if you have done  Authorize Endpoint Addresses step.

https://trailhead.salesforce.com/apex_integration_services/apex_integration_callouts.htm#apex_integration_callouts_authorizing


Hope this helps you!

Please mark it as solved if this helps you so that it will make available for others as a proper solution.

Thanks and Regards
Sandhya
thienthangthienthang
Hi Sandhya, thank you for you reply, the background class in image AnimalCallouts wasn't the target. I was trying to run the following code in Execute Anonymous Window
calculatorServices.CalculatorImplPort calculator = new  calculatorServices.CalculatorImplPort();
Double x = 1.0;
Double y = 2.0;
Double result = calculator.doAdd(x,y);
System.debug(result);

I am really sorry for the misunderstand image. 
thienthangthienthang
This issue have fixed for both calculator sample and challenge by change the end point in the related apex classes which is generated by WSDL. 
change: https://simple-salesforce-soap-server.herokuapp.com/service/calculator
to: https://th-apex-soap-service.herokuapp.com/service/calculator
(the same for trail head challenge in case anyone meet the same issue like me)
change: https://simple-salesforce-soap-server.herokuapp.com/service/parks
to: https://th-apex-soap-service.herokuapp.com/service/parks