SOAP
1.复制webservice页面的soap数据,例如下图:
string用具体的数值代替
2.代码
String soapRequestData = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ " <soap:Header>" + " <RoxvellWebserviceHeader xmlns=\"http://tempuri.org/\">" + " <UserName>"
+ userName
+ " <pMapFloorDateTime>" + "" + "</pMapFloorDateTime>" + " </getMasterV2>" + " </soap:Body>" + "</soap:Envelope>";
URL url;
try {
url = new URL(WebService.GetMasterV2);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
OutputStream os = conn.getOutputStream();
os.write(soapRequestData.getBytes());
InputStream is = conn.getInputStream();
StringBuilder sb=new StringBuilder();
BufferedReader br=new BufferedReader(new InputStreamReader(is,"UTF-8"));
String line="";
while((line=br.readLine())!=null){
sb.append(line);
}
is.close();
os.close();
conn.disconnect();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
记得开启新线程