web service初步了解.手机号码.
来源:互联网 发布:windows 便笺 编辑:程序博客网 时间:2024/05/22 10:43
http://www.webxml.com.cn/zh_cn/index.aspx
http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?op=getMobileCodeInfo
//soap 简单对象访问协议.
通过一个xml协议,让我们可以访问某个对象里面的方法.
一个xml文件发给服务器.
用post请求发送.因为文件比较多.
客户端最主要的的任务就是1解析本地xml文件,2然后发送给服务器.3获得服务器返回的信息.
public void testGetAddress() throws Exception{URL url = new URL("http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx");HttpURLConnection conn = (HttpURLConnection) url.openConnection();conn.setConnectTimeout(5000);conn.setRequestMethod("POST");//得到xml文件,转为流.InputStream is = getClass().getClassLoader().getResourceAsStream("data.xml");//将流转为byte数组.byte [] data = StreamTool.getBytes(is);//得到xml信息.String str = new String(data);//将占位符里面的东西换位手机号码//content.这就是向服务器发送的数据.String content = str.replace("$mobile", "13512345678");System.out.println(content);//conn.setDoOutput(true);conn.setRequestProperty("Content-Type", "application/soap+xml; charset=utf-8");conn.setRequestProperty("Content-Length", content.length()+"");//向服务器设置发送数据.conn.getOutputStream().write(content.getBytes());//得到返回的xml文件.InputStream response = conn.getInputStream();System.out.println( new String( StreamTool.getBytes(response)));
在src下,data.xml文件.
<pre class="html" name="code"><?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <getMobileCodeInfo xmlns="http://WebXml.com.cn/"> <mobileCode>$mobile</mobileCode> <userID></userID> </getMobileCodeInfo> </soap12:Body></soap12:Envelope>
0 0
- web service初步了解.手机号码.
- 初步了解Web Service
- Service初步了解
- Service生命周期初步了解
- Java Message Service初步了解
- 了解Web Service
- web service简单了解
- AXIS Web Service 开发初步
- 关于web service 初步问题
- Web Service快速入门了解
- Web Service快速入门了解
- web Service 初步学习(1)
- Web Service学习与初步认识
- 学习和了解XML,web service,SOA
- Web Service(三):先了解SOA
- webgis本地部署之初步了解web应用程序
- Hadoop初步使用:通过web了解Hadoop的活动
- Service初步
- 望远大光圈拍风景的魅力--不破不立系列(1)
- WWDC2014 IOS8 APP Extensions
- 360 浏览器 浏览器内核控制Meta标签说明文档
- IOCP模型总结(总结回顾)
- SettingsProvider 之 FileObserver
- web service初步了解.手机号码.
- xybb__所遇到乱码问题及解决方法
- SQL server和MYSQL中的自增的一些对比
- 向spring大师致敬
- 建议学习路径:
- 【Android】SlidingMenu属性详解
- poj1330 Nearest Common Ancestors LCA倍增法 或 LCA转RMQ
- GDB调试工具
- SettingsProvider之多用户概念