import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class HttpXmlUtil {
private String method = "POST";
private String charset = "UTF-8";
private String contentType = "text/xml";
public String sendXmlMsg(String address, String xmlMsg) throws Exception {
StringBuilder sb = new StringBuilder();
URL url = new URL(address);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(method);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setInstanceFollowRedirects(true);
conn.setRequestProperty("Content-Type", contentType);
conn.connect();
// 向输出流写出数据
PrintWriter pw = new PrintWriter(conn.getOutputStream());
pw.wr
Http发送xml
最新推荐文章于 2021-03-05 17:36:38 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)