
Hi,
You'll need a Visualforce page with an Apex controller that calls your GlobalWhetherClass — using a <apex:actionSupport> to re-render the cities list when country changes.
public class WeatherController {
public String selectedCountry { get; set; }
public String citiesResult { get; set; }
public List<SelectOption> getCountries() {
return new List<SelectOption>{
new SelectOption('India', 'India'),
new SelectOption('United States', 'United States'),
new SelectOption('United Kingdom', 'United Kingdom')
// Add more as needed
};
}
public void fetchCities() {
if (String.isNotBlank(selectedCountry)) {
GlobalWhetherClass.GlobalWeatherSoap svc = new GlobalWhetherClass.GlobalWeatherSoap();
citiesResult = svc.GetCitiesByCountry(selectedCountry);
}
}
}
<apex:page controller="WeatherController">
<apex:form>
<apex:pageBlock title="Weather Lookup">
<apex:pageBlockSection>
<apex:selectList value="{!selectedCountry}" size="1">
<apex:selectOptions value="{!countries}"/>
<apex:actionSupport event="onchange"
action="{!fetchCities}"
reRender="citiesBlock"/>
</apex:selectList>
</apex:pageBlockSection>
<apex:pageBlockSection id="citiesBlock">
<apex:outputText value="{!citiesResult}" escape="false"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
- User selects a country from the dropdown
- onchange fires fetchCities() via actionSupport
- Controller calls GetCitiesByCountry on your SOAP class
- Result re-renders in citiesBlock without a full page refresh
Make sure
http://www.webservicex.com is added to your Remote Site Settings(Setup → Remote Site Settings) — otherwise the callout will be blocked.
Hope this helps!