日期:2014-05-17 浏览次数:20885 次
public class WetherReport {
public static void main(String[] args) {
Service service = new Service();
try {
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new URL("http://www.ayandy.com/Service.asmx?WSDL"));
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://tempuri.org/getSupportProvince");
String [] weatherReport2 = (String[])call.invoke("getSupportProvince", new String[]{"all"});
System.out.println(weatherReport2);
} catch (ServiceException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (AxisFault e) {
e.printStackTrace();
}
}
}
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;
public class WebServiceTest {
private static final QName SERVICE_NAME = new QName("http://tempuri.org/", "ServiceSoap");
private static final QName PORT_NAME = new QName("http://tempuri.org/", "ServiceSoapPort");
public static void main(String[] args) {
Service service = Service.create(SERVICE_NAME);
String endpointAddress = "http://www.ayandy.com/Service.asmx";
service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
ServiceSoap hw = service.getPort(ServiceSoap.class);
ArrayOfString as = hw.getWeatherbyCityName("上海", TheDayFlagEnum.TODAY);
for(String str : as.getString()) {