首页 > 编程语言 > 详细

使用Java-UrlConnection调用webService接口

时间:2017-01-05 13:10:26      阅读:306      评论:0      收藏:0      [点我收藏+]
URL wsUrl = new URL("http://192.168.1.1:8080/webservice");
        HttpURLConnection conn = (HttpURLConnection) wsUrl.openConnection();
        conn.setDoInput(true);
        conn.setDoOutput(true);
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
        OutputStream os = conn.getOutputStream();
        //创建请求体
        String soap = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:q0=\"http://ws.itcast.cn/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + 
                      "<soapenv:Body> <q0:sayHello><arg0>aaa</arg0>  </q0:sayHello> </soapenv:Body> </soapenv:Envelope>";
        os.write(soap.getBytes());

 

使用Java-UrlConnection调用webService接口

原文:http://www.cnblogs.com/duwenlei/p/6251818.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!