VB控制XML post数据问题
这个发送XML示例示例是使用JAVA语言编写的,哪位高手能否帮转成VB。
String xmlString = " ";
//
byte[] xmlData = xmlString.getBytes("utf8");
String urlStr =
"http://www.zzgsc.gov.cn/jsxm2/upload/XMLUpload/510100002/?pwd=cdfdadmin";
DataInputStream input = null;
java.io.ByteArrayOutputStream out = null;
try {
URL url = new URL(urlStr);
HttpURLConnection urlCon = (HttpURLConnection) url.openConnection();
urlCon.setRequestMethod("POST");
urlCon.setDoOutput(true);
urlCon.setDoInput(true);
urlCon.setUseCaches(false);
urlCon.setRequestProperty("Content-Type", "text/xml; charset=utf8");
//提交表单格式数据
urlCon.setRequestProperty("Content-length", String.valueOf(xmlData.length));
DataOutputStream printout = new DataOutputStream(urlCon.getOutputStream());
printout.write(xmlData);
//表单格式数据内容
printout.flush();
printout.close();
input = new DataInputStream(urlCon.getInputStream());
byte[] rResult;
out = new java.io.ByteArrayOutputStream();
byte[] bufferByte = new byte[256];
int l = -1;
int downloadSize = 0;
while ((l = input.read(bufferByte)) > -1) {
downloadSize += l;
out.write(bufferByte, 0, l);
out.flush();
}
rResult = out.toByteArray();
String reXML = new String(rResult,"utf8");
System.out.println(reXML);
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
out.close();
input.close();
}catch (Exception ex) {
}
}