Skip to main content
I am getting this error when trying to finish the challenge in Apex SOAP Callouts.i tried number of ways of code but no luck.

 

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.

 

park Locator:

 

public class ParkLocator {

 

    public static String[] country(String country){

 

        ParkService.ParksImplPort Locator = new ParkService.ParksImplPort();

 

        return Locator.byCountry(country);

 

    }

 

}

 

Park locator test

 

@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<String>{'Garner State Park', 'Fowler Park', 'Hoosier National Forest Park'}, result);

 

    }

 

}

 

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();

 

            response_x.return_x = new List<String>{'Garner State Park', 'Fowler Park', 'Hoosier National Forest Park'};

 

                response.put('response_x',response_x);

 

        }

 

}

 

Any help is highly appreciated. Thanks in advance.
2 件の回答
  1. 2021年5月24日 23:37
    Hi Mohammad,

     

    Have you set up a remote site?
0/9000