3

I am getting error The Apex class 'ParkLocator' does not appear to be calling the SOAP endpoint.

Salesforce Trailhead requirement is 1. Use WSDL2Apex to generate a class called 'ParkService' in public scope using this https://th-apex-soap-service.herokuapp.com/assets/parks.xml WSDL file.

  1. Create a class called 'ParkLocator' that has a 'country' method that uses the 'ParkService' class and returns an array of available park names for a particular country passed to the web service. Possible country names that can be passed to the web service include Germany, India, Japan and United States.

  2. Create a test class named ParkLocatorTest that uses a mock class called ParkServiceMock to mock the callout response.


public class ParkLocator {
            public static string[] country(String country) {
                parkService.parksImplPort park = new parkService.parksImplPort();
                return park.byCountry(country);
            }
}

I have a parksServices class

  //Generated by wsdl2apex
 public class parksServices {
        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/', 'parksServices'};
            public String[] byCountry(String arg0) {
                parksServices.byCountry request_x = new parksServices.byCountry();
                request_x.arg0 = arg0;
                parksServices.byCountryResponse response_x;
                Map<String, parksServices.byCountryResponse> response_map_x = new Map<String, parksServices.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',
                  'parksServices.byCountryResponse'}
                );
                response_x = response_map_x.get('response_x');
                return response_x.return_x;
            }
        }
    }
5

Change your third line in ParkLocator class with

 parkService.ParksImplPort park = new parkService.ParksImplPort();

ParksImplPort is case sensitive here.

Answered here

-1

Based on my experience with this trailhead it looks like you're missing the remote site setting.

Did you add the remote site? https://th-apex-soap-service.herokuapp.com is the one for this trail.

Not the answer you're looking for? Browse other questions tagged or ask your own question.