VB控制XML post数据问题

yinxiaodan 2011-06-12 11:01:30
这个发送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) {

}
}

...全文
71 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yinxiaodan 2011-06-13
  • 打赏
  • 举报
回复
如果能帮我解决XML,可以提供资金,具体详谈,联系9765569

1,502

社区成员

发帖
与我相关
我的任务
社区描述
VB 网络编程
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧