赞
踩
- //java post请求 xml
- try {
- String cdnaddress = ConfigUtil.getConfig("cdnaddress");
- URL wsUrl = new URL(cdnaddress);
-
- HttpURLConnection conn = (HttpURLConnection) wsUrl.openConnection();
-
- conn.setDoInput(true);//有输入
- conn.setDoOutput(true);//有输出
- conn.setRequestMethod("POST");
- conn.setRequestProperty("Content-Type", "text/xml;charset=utf-8");
- //从配置文件取得信息
- String correlateID = correlateid;
- String r = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n"+
- "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n"+
- "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> \n"+
- "<soapenv:Body> \n"+
- "<ns1:ContentDeployReq \n"+
- "soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" \n"+
- " xmlns:ns1=\"iptv\"> \n"+
- "<CMSID xsi:type=\"xsd:string\">" + cmsid +"</CMSID> \n"+
- "</ns1:ContentDeployReq> \n"+
- "</soapenv:Body> \n"+
- "</soapenv:Envelope>";
-
- OutputStream os = conn.getOutputStream();
- os.write(r.getBytes());
-
- InputStream is = conn.getInputStream();
-
- byte[] b = new byte[1024];
- int len = 0;
- String s1 = "";
-
- while( (len = is.read(b)) != -1){
- s1 += new String(b,0,len,"UTF-8");
- }
- logger.info("通知CDN:"+s1);
- os.close();
- is.close();
- conn.disconnect();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。