http://webservice.webxml.com.cn/WebServices/TrainTimeWebService.asmx
解析以上soap webservice
所需jar soap。jar
import java.io.IOException;
import javax.xml.soap.SOAPEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
public class train {
static String url = "http://www.webxml.com.cn/WebServices/TrainTimeWebService.asmx";
static String ns = "http://WebXml.com.cn/";
static String method = "getStationAndTimeByStationName";
public static void main(String[] args) throws IOException, XmlPullParserException {
HttpTransportSE hts = new HttpTransportSE(url);
SoapSerializationEnvelope sse = new SoapSerializationEnvelope(
SoapSerializationEnvelope.VER11);
SoapObject so = new SoapObject(ns, method);
so.addProperty("StartStation", "合肥");
so.addProperty("ArriveStation", "阜阳");
so.addProperty("UserID", null);
sse.bodyOut = so;
sse.dotNet = true;
hts.call(ns + method, sse);
System.out.println(sse.bodyIn);
}
}