If the customer provides the wsdl access link and the corresponding interface documentation, how to call the corresponding interface.
This example generates a client through eclipse, calls and tests the interface
1.File--->new--->other--->Web Service Client--->Enter wsdl access link--->finish. The project is newly created successfully.
2. View the automatically generated java code and carefully analyze the WeatherWSLocator and WeatherWSSoap classes.
3. Write test methods. The Main method can be tested. The two examples in the appendix are one is the webService interface of the weather, and the other is to get the hand
The webService interface of the home of the machine number. The interface was originally free, but later began to charge, and the user ID needs to be submitted. But the country of acquisition
The interface of home, province, and region can still be used normally. This is just an example, and the interface is available.
[The following is the Main method]
public static void main(String[] args) throws Exception {
// Create a WeatherWS factory
WeatherWS weatherWS = new WeatherWSLocator();
// Create a WeatherWSSoap object based on the factory
WeatherWSSoap weatherWSSoap = weatherWS.getWeatherWSSoap();
// Call the getRegionCountry method provided by WebService to get all countries
String[] regionCountry = weatherWSSoap.getRegionCountry();
for (int i = 0; i < regionCountry.length; i++) {
System.out.println(regionCountry[i]);
}
// Call the getRegionCountry method provided by WebService to get all provinces
String[] province = weatherWSSoap.getRegionProvince();
for (int i = 0; i < province.length; i++) {
System.out.println(province[i]);
}
// Call the getRegionProvince method provided by WebService to get the districts and counties under all provinces
String[] city = weatherWSSoap.getSupportCityString("31111");
for (int i = 0; i < city.length; i++) {
System.out.println(city[i]);
}
// Call the getWeather method provided by WebService to get the weather of the specified location
String[] weather = weatherWSSoap.getWeather("1951", "0");
for (int i = 0; i < weather.length; i++) {
System.out.println(weather[i]);
}
// Get the national address [by WeatherWSSoapProxy, the second way]
WeatherWSSoapProxy weatherProxy = new WeatherWSSoapProxy();
GetRegionDatasetResponseGetRegionDatasetResult RegionDatasetResult = weatherProxy.getRegionDataset();
MessageElement[] msgs = RegionDatasetResult.get_any();
for (MessageElement messageElement : msgs) {
System.out.println(messageElement.getAsString());
}
// Get the districts and counties under the province [obtained by WeatherWSSoapProxy, the second way]
GetSupportCityDatasetResponseGetSupportCityDatasetResult cityDatasetResult = weatherProxy.getSupportCityDataset("31111");
MessageElement[] element = cityDatasetResult.get_any();
for (MessageElement messageElement : element) {
System.out.println(URLDecoder.decode(messageElement.getAsString(), "UTF-8"));
}
}