You need to sign in to do that
Don't have an account?

Trailhead Apex Integration Services - Apex SOAP Callouts - The Apex class 'ParkLocator' does not appear to be calling the SOAP endpoint.
Hi all,
I'm stuck in the Apex Integration Services - Apex SOAP Callouts challenge with the following message "The Apex class 'ParkLocator' does not appear to be calling the SOAP endpoint.".
Could you please advise ?
I'm stuck in the Apex Integration Services - Apex SOAP Callouts challenge with the following message "The Apex class 'ParkLocator' does not appear to be calling the SOAP endpoint.".
Could you please advise ?
If you had entered ParkService originally it would have generated this code in this manner. Not sure if it didn't overwrite these classes or something.
Jeff Douglas
Trailhead Developer Advocate
All Answers
You can try refactoring your Apex to work with this class, but it's easier to delete the Apex class(es) and start the challenge from scratch with this in mind.
I have deleted my classes and imported again the wsdl paying attention to the name but I still into the same issue.
All the classes are compiling fine.
here are my classes :
If you had entered ParkService originally it would have generated this code in this manner. Not sure if it didn't overwrite these classes or something.
Jeff Douglas
Trailhead Developer Advocate
I'm definitely not used to pay attention to the case when writting apex.
Thanks a lot.
There's been a lot of confusion around importing the WSDL file and getting the naming convention correct. Could we get an updated WSDL with the correct Schema, so that the name is correct off the bat, and avoid further issues? Or is the intent to have the challenge taker realize the difference, and adjust their Apex accordingly?
If the latter, then I'd suggest strongly hinting at the fact you need to change the name of your Apex class when importing the WSDL.
Use WSDL2Apex to generate a class called 'ParkService' in public scope using this WSDL file.
I'll change it to:
Use WSDL2Apex to generate a class called 'ParkService' in public scope using this WSDL file. After you click the 'Parse WSDL' button don't forget to change the name of the Apex Class Name from 'parksServices' to 'ParkService'.
Thanks James!
Jeff Douglas
Trailhead Developer Advocate
I have followed all the steps mentioned above but still getting the error :
Following are my classes :
Test class is also working correctly and giving expected coverage.
What is going wrong in this ?
Regards,
Ajay
I used following code and everything went fine for me :
ParkLocator
ParkLocatorTest
ParkServiceMock
ParkService (Default from WSDL2Apex)
I queued Run All and checked challenge after a while
I cleared the challenge. Not sure what is the reason. I had not run the Run All in my previous steps today I run that and it worked.
Regards,
Ajay
I ve bee trying to check my challenge after writing these 3 classes require to complete it, I am getting below error.
Challenge Not yet complete... here's what's wrong:
The Apex class 'ParkLocator' does not appear to be calling the SOAP endpoint.
This is my ParkLocator class.
Look at the best answer (in green) for this thread. It should do the trick.
Jeff Douglas
Trailhead Developer Advocate
I really appreciate your help. Thank you.
Jeff Douglas
Trailhead Developer Advocate
Been working on this challenge. Unknowingly I had named test class as "ParkServiceTest" instead of "ParkLocatorTest". Now I created new class with the required name and did necessary changes. After running all test I am still Unable to find "ParkLocatorTest" in my code coverage panel. When I checked in for challenge it prompted
"Challenge Not yet complete... here's what's wrong: No Apex test class named 'ParkLocatorTest' was found."
Even though I can still see that class in Apex classes through setup. Can anyone help me out please.
If you want to email me (jdouglas at salesforce) your login credentials I can take a peek for you. Please also send me the URL to the unit of the module you are having problems with.
Jeff Douglas
Trailhead Developer Advocate
Very strange issue! Your class definitely exists but for some reason the Tooling API couldn't find it. Maybe some type of special characters in the name of the class or something? Not sure. Anyway, I deleted your class and recreated it and it works fine now. Go ahead and check the challenge test again.
Jeff Douglas
Trailhead Developer Advocate
Yeah! I accept that, able to see the same class with old name in my recent item too but now its different though. Anyways done with my challenge. Appriciate your help. Thank you.
Class generated by WSDL:
Execute anonymous results of ParkLocator.country('Germany'); yields below so I know it calls the webservice:
Mystified
Stupid thing but change line #3 in ParkLocator to the following:
I've change this test but it won't go into effect till our next release. Sorry for the inconvenience!
Jeff Douglas
Trailhead Developer Advocate
First of all, thank you for looking into this and suggesting a workaround. However, with the revised class code (space removed), I get the same error: The Apex class 'ParkLocator' does not appear to be calling the SOAP endpoint.
Still mystified.
Eric
Send me your credentials to jdouglas at salesforce and I'll take a peek.
Jeff Douglas
Trailhead Developer Advocate
Specifically, the argument to method country() has to have a different value than "country". You can see I changed it to "theCountry" and it passed.
As an aside, a future Apex Trailhead challenge could be to write a parser in Apex looking for compliance in coded Apex :-)
Jeff Douglas
Trailhead Developer Advocate
You could also inlcude in the Test Spec that you need to use ParksImplPort(), that woud go along way for people trying to guess what you
exposed.
As required by this challenge - I created the ParkLocator.apxc, ParkLocatorTest.apxc, ParkLocatorMock.apxc.
Testing the code shows 100% coverage and I also successfully executed the code below, in the 'Execute Anonymous' Window: and the logs shows the list of parks fine. However when I click on the 'Check Challenge' button, it throws this error:
Challenge Not yet complete... here's what's wrong:
No Apex class named 'ParkLocator' was found.
ParkLocator: Can someone tell me what I might be missing? I am able to open this file on my 'Developer Console' too, so not sure why the Trailhead challenge does not see this file. I have also tried closing my browser completely and logging back afresh with no avail.
Thanks,
Joe
Thank you James, but that did not help much, still getting the same error.
Lesson learned :).
Thanks to Uvais Komath, I found when the method recieved 'India' as a parameter the output was the following list of strings: ['Lal Bhag', 'Cubbon Park', 'Pazhassi Dam']...
Where could i have found this information??
Thanks :)
1 ParkLocator Class
2 ParkLocator Class
Failed code:
Passed code:
I had alot of trouble trying to find the expected return value of the country Method in ParkLocator Class.
Thanks to Uvais Komath, I found when the method recieved 'India' as a parameter the output was the following list of strings: ['Lal Bhag', 'Cubbon Park', 'Pazhassi Dam']...
Where could i have found this information??
You can probably do something like this to the above code and check the results while running it via "Open Execute Anonoymous Window" and set the mock responses accordingly.
So here is what you gonna run in the execute window ParkLocator.country('India');
Check the logs and set the mock responses..
public class ParkLocator {
public static string[] country(String country) {
ParkService.ParksImplPort prk = new ParkService.ParksImplPort();
String[] result = prk.byCountry(country);
system.debug(result);
return prk.byCountry(country);
}
}
thanks hope this helps and answer your query.
Would you please tell me how to fix this issue? Thank you.
- make clear what is case sensitive and what not
- update the WSDL file to contain the correct end-point as Johan pointed out correctly
Let me check with Jeff Douglas internally.Best Regards
Gerard Braat, Program Architect
Jeff Douglas
Trailhead Developer Advocate
I called my parklocator.country(). according to my code below its not returning the same result as compiles but result printed on the debug log as expected.
Can anyone help with this
public class ParkLocator {
public static List<string> Country(string countryname){
List<string> result =new List<string>();
List<string> Availablecountrynames = new List<string>{'India', 'Germany', 'Japan', 'United States'};
for (string i: availablecountrynames){
if (i == countryname){
ParkService.ParksImplPort parknames = new parkService.ParksImplPort();
result = parknames.bycountry(countryname);
system.debug(result);}
else {break;}
//{system.debug('select an apropriate country');}
}
return result;}
}
Please Upadte the Code of Parkservice Class then it will work fine
ParkLoacater Class
Mock for test class
Test Class
set the remote site setting
check Setup->Security->Remote site settings. endpoint = https://th-apex-soap-service.herokuapp.com/service/parks
Cheers Enjoy !
Don't Forget to choose the best annser ;)
"Challenge Not yet complete... here's what's wrong:
This challenge has already been completed"
Can somebody tell me its meaning please
Have you tried my solution.
It is working fine.....
ParkService.ParksImplPort park = new ParkService.ParksImplPort();
already with capital P - but obviously I didn't. Sorry for trouble!
I am getting same error
"The Apex class 'ParkLocator' does not appear to be calling the SOAP endpoint."
And I tried all the solutions provided here, rerun the test, but still getting same error.
Here are my mock n Test classes
What is wrong?
I have set remote site url as
If still getting an error then replace your ParkLocator class to below code.
public class ParkLocator{
public static string[] country(string thecountry){
ParkService.ParksImplPort park = new ParkService.ParksImplPort();
return park.byCountry(thecountry);
}
}
public class ParkService {
public class byCountryResponse {
public String[] return_x = new String[] {}; //original : public String[] return_x ;
private String[] return_x_type_info = new String[]{'return','http://parks.services/',null,'0','-1','false'};
private String[] apex_schema_type_info = new String[]{'http://parks.services/','false','false'};
private String[] field_order_type_info = new String[]{'return_x'};
}
Step 1 - First generated the Apex classes from Generate from WSDL
//Generated by wsdl2apex
public class ParkService {
public class byCountryResponse {
public String[] return_x;
private String[] return_x_type_info = new String[]{'return','http://parks.services/',null,'0','-1','false'};
private String[] apex_schema_type_info = new String[]{'http://parks.services/','false','false'};
private String[] field_order_type_info = new String[]{'return_x'};
}
public class byCountry {
public String arg0;
private String[] arg0_type_info = new String[]{'arg0','http://parks.services/',null,'0','1','false'};
private String[] apex_schema_type_info = new String[]{'http://parks.services/','false','false'};
private String[] field_order_type_info = new String[]{'arg0'};
}
public class ParksImplPort {
public String endpoint_x = 'https://th-apex-soap-service.herokuapp.com/service/parks';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
private String[] ns_map_type_info = new String[]{'http://parks.services/', 'ParkService'};
public String[] byCountry(String arg0) {
ParkService.byCountry request_x = new ParkService.byCountry();
request_x.arg0 = arg0;
ParkService.byCountryResponse response_x;
Map<String, ParkService.byCountryResponse> response_map_x = new Map<String, ParkService.byCountryResponse>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://parks.services/',
'byCountry',
'http://parks.services/',
'byCountryResponse',
'ParkService.byCountryResponse'}
);
response_x = response_map_x.get('response_x');
return response_x.return_x;
}
}
}
-----------------------------------------------------------------------------------
Step - 2
------------------------------------------------------------------------------------
public class ParkLocator {
public static String[] country(String ctry) {
ParkService.ParksImplPort park = new ParkService.ParksImplPort();
return park.byCountry(ctry);
}
}
------------------------------------------------------------------------------------------
Step 3
---------------------------------------------------------------------------------------
@isTest
global class ParkServiceMock implements WebServiceMock {
global void doInvoke(
Object stub,
Object request,
Map<String, Object> response,
String endpoint,
String soapAction,
String requestName,
String responseNS,
String responseName,
String responseType) {
// start - specify the response you want to send
ParkService.byCountryResponse response_x = new ParkService.byCountryResponse();
response_x.return_x = new List<String>{'Hamburg Wadden Sea National Park', 'Hainich National Park', 'Bavarian Forest National Park'};
response.put('response_x', response_x);
}
}
--------------------------------------
Step 4
----------------------------------
@isTest
private class ParkLocatorTest {
@isTest public static void testCallout() {
// This causes a fake response to be generated
Test.setMock(WebServiceMock.class, new ParkServiceMock());
String country = 'Germany';
String[] result = ParkLocator.Country(country);
System.debug(result);
String resultEx ='Hamburg Wadden Sea National Park, Hainich National Park, Bavarian Forest National Park';
System.assertEquals(resultEx,resultEx);
}
}
---------------------------------------------------------------
Happy Coding :0
Worked Nicely Thanks a lot…
Best Answer...
The generated WSDL class you are calling from the ParkLocator call is case sensitive. So, try changing the syntax from "parkService.ParksImplPort parkContry = new parkService.ParksImplPort();" to
"ParkService.ParksImplPort parkContry = new ParkService.ParksImplPort();"
it worked by the following code.thanks.
public class ParkLocator{ public static List<String> country(String countryName){ ParkService.ParksImplPort park = new ParkService.ParksImplPort(); return (List<String>)park.byCountry(countryName); } }
The 'ParkLocator' class did not achieve 100% code coverage via your test methods. Make sure that you chose 'Run All' tests in the Developer Console at least once before attempting to verify this challenge.
Tests work fine everytime I check.
Jeff Douglas
This one got me, too!
Suggest you add the point about the upper case P...
Use WSDL2Apex to generate a class called 'ParkService' in public scope using this WSDL file. After you click the 'Parse WSDL' button don't forget to change the name of the Apex Class Name from 'parksServices' to 'ParkService' taking special note of the capital initial letter.
I must acknowledge that this "Apex Web Services" trailhead module requires quite some degree of thoroughness and accuracy when accomplishing tasks :-)
Credit @Varun Singh!
1public class ParkLocator {
2 public static string[] country(String country) {
3 parkService.parksImplPort park = new parkService.parksImplPort();
4 return park.byCountry(country);
5 }
6}
01//Generated by wsdl2apex
02
03public class ParkService {
04 public class byCountryResponse {
05 public String[] return_x;
06 private String[] return_x_type_info = new String[]{'return','http://parks.services/',null,'0','-1','false'};
07 private String[] apex_schema_type_info = new String[]{'http://parks.services/','false','false'};
08 private String[] field_order_type_info = new String[]{'return_x'};
09 }
10 public class byCountry {
11 public String arg0;
12 private String[] arg0_type_info = new String[]{'arg0','http://parks.services/',null,'0','1','false'};
13 private String[] apex_schema_type_info = new String[]{'http://parks.services/','false','false'};
14 private String[] field_order_type_info = new String[]{'arg0'};
15 }
16 public class ParksImplPort {
17 public String endpoint_x = 'https://th-apex-soap-service.herokuapp.com/service/parks';
18 public Map<String,String> inputHttpHeaders_x;
19 public Map<String,String> outputHttpHeaders_x;
20 public String clientCertName_x;
21 public String clientCert_x;
22 public String clientCertPasswd_x;
23 public Integer timeout_x;
24 private String[] ns_map_type_info = new String[]{'http://parks.services/', 'ParkService'};
25 public String[] byCountry(String arg0) {
26 ParkService.byCountry request_x = new ParkService.byCountry();
27 request_x.arg0 = arg0;
28 ParkService.byCountryResponse response_x;
29 Map<String, ParkService.byCountryResponse> response_map_x = new Map<String, ParkService.byCountryResponse>();
30 response_map_x.put('response_x', response_x);
31 WebServiceCallout.invoke(
32 this,
33 request_x,
34 response_map_x,
35 new String[]{endpoint_x,
36 '',
37 'http://parks.services/',
38 'byCountry',
39 'http://parks.services/',
40 'byCountryResponse',
41 'ParkService.byCountryResponse'}
42 );
43 response_x = response_map_x.get('response_x');
44 return response_x.return_x;
45 }
46 }
47}
@isTest
private class ParkLocatorTest {
@isTest
public static void testCallout() {
// This causes a fake response to be generated
Test.setMock(WebServiceMock.class, new ParkServiceMock());
// Call the method that invokes a callout
//Double x = 1.0;
//Double result = AwesomeCalculator.add(x, y);
String country = 'Germany';
String[] result = ParkLocator.Country(country);
// Verify that a fake result is returned
System.assertEquals(new List<String>{'Hamburg Wadden Sea National Park', 'Hainich National Park', 'Bavarian Forest National Park'}, result);
}
}
01@isTest
02global class ParkServiceMock implements WebServiceMock {
03 global void doInvoke(
04 Object stub,
05 Object request,
06 Map<String, Object> response,
07 String endpoint,
08 String soapAction,
09 String requestName,
10 String responseNS,
11 String responseName,
12 String responseType) {
13 // start - specify the response you want to send
14 parkService.byCountryResponse response_x = new parkService.byCountryResponse();
15 response_x.return_x = new List<String>{'Hamburg Wadden Sea National Park', 'Hainich National Park', 'Bavarian Forest National Park'};
16
17 //calculatorServices.doAddResponse response_x = new calculatorServices.doAddResponse();
18 //response_x.return_x = 3.0;
19 // end
20 response.put('response_x', response_x);
21 }
22}
https://movidv.blogspot.com/
Auto news reporter (http://www.autonewsreporter.com/)
The Enumeration (https://www.theenumeration.com/)
I am getting below error.
Executing the 'country' method on 'ParkLocator' failed. Make sure the method exists with the name 'country', is public and static, accepts a String, and returns an array of Strings from the web service.
Goto-> Setup-> Remote Site settings-> New-> Add URL 'https://th-apex-soap-service.herokuapp.com/service/parks'
"Executing the 'country' method on 'ParkLocator' failed. Make sure the method exists with the name 'country', is public and static, accepts a String, and returns an array of Strings from the web service."
Even though the code and class is present.....the code ...passes the challenge:
1. generate apex class using wsdl2 and the script given in the trailhead
2. rename the class to ParkService.
3. ParkLocator class:
public class ParkLocator {
public static List<string> country(string country){
ParkService.ParksImplPort parkservice = new ParkService.ParksImplPort ();
return parkservice.byCountry(country);
}
}
4.ParkServiceMock class:
@IsTest
global class ParkServiceMock implements WebServiceMock {
global void doInvoke(
Object stub,
Object request,
Map<String, Object> response,
String endpoint,
String soapAction,
String requestName,
String responseNS,
String responseName,
String responseType)
{
List<string> parks = new List<string>();
parks.add('Yosemite');
parks.add('Yellowstone');
parks.add('Another Park');
// start - specify the response you want to send
ParkService.byCountryResponse response_x =
new ParkService.byCountryResponse();
response_x.return_x = parks;
// end
response.put('response_x', response_x);
}
}
5. ParkLocatorTest:
IsTest
public class ParkLocatorTest {
@IsTest static void testcallout()
{
Test.setMock(WebServiceMock.class, new ParkServiceMock());
string country = 'United State';
List<string> result = ParkLocator.country(country);
List<string> parks = new List<string>();
parks.add('Yosemite');
parks.add('Yellowstone');
parks.add('Another Park');
system.assertEquals(parks,result);
}
}
This code Worked For me.
2. Second check the Speling for "ParksImplPort" or "ParkService".
3. If your getting the error for Country Method does not exist.then use this "debug" code line for "open execute anonymous window"
system.debug(ParkLocator.country('Japan'));
4. Hey, don't forget to set up the Remote site ..after that, I was able to pass the challenge.
ParkService
public class ParkLocator {
public static list country(string country) {
ParkService.ParksImplPort parkservice = new ParkService.ParksImplPort();
return Parkservice.byCountry(country);
}
}
--------------------------------------------------------
ParkLocaterTest
@isTest
private class ParkLocatorTest {
testMethod static void testCallout(){
Test.setMock(WebServiceMock.class, new ParkServiceMock());
String country = 'United States';
String[] result = ParkLocator.country(country);
System.assertEquals(new List{'Garner State Park', 'Fowler Park', 'Hoosier National Forest Park'}, result);
}
}
----------------------------------------
ParkServiceMoak
@isTest
global class ParkServiceMock implements WebServiceMock{
global void doInvoke(
Object stub,
Object request,
Map response,
String endpoint,
String soapAction,
String requestName,
String responseNS,
String responseName,
String responseType) {
ParkService.byCountryResponse response_x = new ParkService.byCountryResponse();
response_x.return_x = new List{'Garner State Park', 'Fowler Park', 'Hoosier National Forest Park'};
response.put('response_x',response_x);
}
}
-----------------------------------------------
work for me .hope work for you too
have a good day
https://www.governmentkischeme.com/about-us
Best Video Player App For Android
https://play.google.com/store/apps/details?id=com.zeasoft.videoplayer
https://play.google.com/store/apps/details?id=com.whatsappstatus.saverforandroid
I have checked all the above answers and followed all the steps, still I'm getting this error "System.TypeException: Mock object doesn't implement the supplied interface".
Here are my classes:
ParkLocator:
public class ParkLocator {
public static List<String> country(String country){
ParkService.ParksImplPort park = new ParkService.ParksImplPort();
return park.byCountry(country);
}
}
ParkLocatorTest:
@isTest
public class ParkLocatorTest {
@isTest static void testCallout(){
Test.setMock(WebServiceMock.class, new ParkServiceMock());
String country = 'India';
System.assertEquals(new List<String>{'Lal Bhag', 'Cubbon Park', 'Pazhassi Dam'}, ParkLocator.country(country));
}
}
ParkServiceMock:
global class ParkServiceMock {
global void doInvoke(
Object stub,
Object request,
Map<String, Object> response,
String endpoint,
String soapAction,
String requestName,
String responseNS,
String responseName,
String responseType) {
// start - specify the response you want to send
ParkService.byCountryResponse response_x = new ParkService.byCountryResponse();
response_x.return_x = new List<String>{'Lal Bhag', 'Cubbon Park', 'Pazhassi Dam'};
response.put('response_x', response_x); }
}
I am getting below error.
Executing the 'country' method on 'ParkLocator' failed. Make sure the method exists with the name 'country', is public and static, accepts a String, and returns an array of Strings from the web service.
AsyncParkService
//Generated by wsdl2apex
public class AsyncParkService {
public class byCountryResponseFuture extends System.WebServiceCalloutFuture {
public String[] getValue() {
ParkService.byCountryResponse response = (ParkService.byCountryResponse)System.WebServiceCallout.endInvoke(this);
return response.return_x;
}
}
public class AsyncParksImplPort {
public String endpoint_x = 'https://th-apex-soap-service.herokuapp.com/service/parks';
public Map<String,String> inputHttpHeaders_x;
public String clientCertName_x;
public Integer timeout_x;
private String[] ns_map_type_info = new String[]{'http://parks.services/', 'ParkService'};
public AsyncParkService.byCountryResponseFuture beginByCountry(System.Continuation continuation,String arg0) {
ParkService.byCountry request_x = new ParkService.byCountry();
request_x.arg0 = arg0;
return (AsyncParkService.byCountryResponseFuture) System.WebServiceCallout.beginInvoke(
this,
request_x,
AsyncParkService.byCountryResponseFuture.class,
continuation,
new String[]{endpoint_x,
'',
'http://parks.services/',
'byCountry',
'http://parks.services/',
'byCountryResponse',
'ParkService.byCountryResponse'}
);
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Class ParkLocator
public class ParkLocator {
public static String[] country(String country){
ParkService.ParksImplPort parks = new ParkService.ParksImplPort();
String[] parksname = parks.byCountry(country);
return parksname;
}
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ParkLocatorTest
@isTest
private class ParkLocatorTest{
@isTest
static void testParkLocator() {
Test.setMock(WebServiceMock.class, new ParkServiceMock());
String[] arrayOfParks = ParkLocator.country('India');
System.assertEquals('Park1', arrayOfParks[0]);
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ParkServiceMock
@isTest
global class ParkServiceMock implements WebServiceMock {
global void doInvoke(
Object stub,
Object request,
Map<String, Object> response,
String endpoint,
String soapAction,
String requestName,
String responseNS,
String responseName,
String responseType) {
ParkService.byCountryResponse response_x = new ParkService.byCountryResponse();
List<String> lstOfDummyParks = new List<String> {'Park1','Park2','Park3'};
response_x.return_x = lstOfDummyParks;
response.put('response_x', response_x);
}
}