Created
December 6, 2023 08:20
-
-
Save burlistic/e8e858fb826469e4742dec494e7bef61 to your computer and use it in GitHub Desktop.
APEX SOAP Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ParkLocator { | |
public static List<String> country(String country){ | |
ParkService.ParksImplPort prkSvc = new ParkService.ParksImplPort(); | |
return prkSvc.byCountry(country); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
public class ParkLocatorTest { | |
@isTest public static void countyTest(){ | |
Test.setMock(WebServiceMock.class, new ParkServiceMock()); | |
String country = 'United States'; | |
System.assertEquals(new List<String>{'Yosemite','Sequonia','Crater Lake'}, ParkLocator.country(country)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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>{'Yosemite','Sequonia','Crater Lake'}; | |
// end | |
response.put('response_x', response_x); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment