如何用post将xml文件发到网络上
如何用post将xml文件发到网络上。求解。。。。。 --------------------编程问答-------------------- xml文件是么?Apache的HttpEntity接口有一个实现类FileEntity
用xml文件生成这个对象,然后HttpClient用post方式通信就好了 --------------------编程问答-------------------- 能不能在详细点啊?我现在比较急。多谢了。有代码最好了。 --------------------编程问答--------------------
private DefaultHttpClient httpClient;
private HttpEntity httpEntity;
private HttpResponse httpResponse;
private HttpPost httpPost;
public void doPost(String url, String filePath)
{
try
{
httpClient = new DefaultHttpClient();
httpPost = new HttpPost(url);
httpEntity = new FileEntity(new File(""), "text/xml");
httpPost.setEntity(httpEntity);
httpResponse = httpClient.execute(httpPost);
} catch (Exception e)
{
} finally
{
httpClient.getConnectionManager().shutdown();
}
}
大概就是这样了,httpResponse就是你得到的响应,根据情况再转类型吧
还有,new FileEntity的第二个参数是contentType,根据你实际上传的文件格式确定 --------------------编程问答-------------------- 多谢了
补充:移动开发 , Android