用HTTP GET调用web service
来源:互联网 发布:讨鬼传2女生捏脸数据 编辑:程序博客网 时间:2024/06/05 05:08
下面的网址提供了国内飞机航班时刻表 WEB 服务
http://webservice.webxml.com.cn/webservices/DomesticAirline.asmx
wsdl如下:
http://webservice.webxml.com.cn/webservices/DomesticAirline.asmx?wsdl
调用web service可以采用很多方式 比如axis2、xfire、cxf都可以根据wsdl反向生成客户端代码 简化开发
下面我采用的是http get的方式调用其web service,采用的是HttpClient4
http://webservice.webxml.com.cn/webservices/DomesticAirline.asmx
wsdl如下:
http://webservice.webxml.com.cn/webservices/DomesticAirline.asmx?wsdl
调用web service可以采用很多方式 比如axis2、xfire、cxf都可以根据wsdl反向生成客户端代码 简化开发
下面我采用的是http get的方式调用其web service,采用的是HttpClient4
- import java.net.URLEncoder;
- import org.apache.http.client.HttpClient;
- import org.apache.http.client.ResponseHandler;
- import org.apache.http.client.methods.HttpGet;
- import org.apache.http.impl.client.BasicResponseHandler;
- import org.apache.http.impl.client.DefaultHttpClient;
- import org.apache.http.params.HttpProtocolParams;
- /**
- * @author Tony Shen
- *
- */
- public class DomesticAirlineTest {
- public static void main(String[] args) throws Exception{
- String url = "/webservices/DomesticAirline.asmx/getDomesticAirlinesTime";
- String host = "www.webxml.com.cn";
- String param = "startCity="+URLEncoder.encode("北京", "utf-8")+"&lastCity="+URLEncoder.encode("上海", "utf-8")+"&theDate=&userID=";
- HttpClient httpclient = new DefaultHttpClient();
- httpclient.getParams().setParameter(HttpProtocolParams.HTTP_CONTENT_CHARSET,"UTF-8");
- HttpGet httpget = new HttpGet("http://"+host+url+"?"+param);
- ResponseHandler<String> responseHandler = new BasicResponseHandler();
- String responseBody = httpclient.execute(httpget, responseHandler);
- System.out.println(responseBody);
- httpclient.getConnectionManager().shutdown();
- }
- }
- 用HTTP GET调用web service
- 通过http-Get请求调用Web Service (C#)
- HTTP-GET调用Web服务
- 在.net 2.0环境下开发的web service ,支持http get方式的调用
- 使用HTTP GET调用Web Services方法
- 手动发送HTTP请求调用Web Service
- 手动发送HTTP请求调用Web Service
- Android----用HTTP的get,post,HttpClient三种方式向web service提交文本数据
- 通过get或post的方式来调用web service
- 使用ASP.NET AJAX异步调用Web Service和页面中的类方法(4):异步通讯层生成的客户端代理类、使用HTTP GET进行调用
- Domino代理调用远程Web Service(HTTP POST)
- ABAP利用HTTP调用要用户验证的web service
- XML Web Service初体验: HTTP-GET, HTTP-POST and SOAP的比较
- XML Web Service初体验: HTTP-GET, HTTP-POST and SOAP的比较
- XML Web Service初体验: HTTP-GET, HTTP-POST and SOAP的比较
- Web Service进阶(三)HTTP-GET, HTTP-POST and SOAP的比较
- 用cxf公布和调用web service
- 用cxf发布和调用web service
- RadioButtonList获取值
- Android JNI实例
- mini2440 nfs 挂载到ubuntu
- C++接口的设计和声明
- DNS负载均衡与负载均衡器两种方案的选择
- 用HTTP GET调用web service
- ARM专题之字节对齐
- 关于自增运算符++a和a++的问题
- QTP 循环执行巧设置
- HDU1200——字符串处理
- weather
- dbcp配置--官方文档中文版本
- Android JNI实例
- 使用CFE加载vxWorks