1.

 2500多个城市天气预报 WEB服务公用事业
Endpoint:http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx
Disco:http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?disco
WSDL:http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl 代码如下: import java.rmi.RemoteException; import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException; import org.apache.axis.client.Call;
import org.apache.axis.client.Service; public class Weather {
public static void main(String[] args) throws ServiceException,
RemoteException {
String cityCode = "北京";
String userId = "";
// http://WebXml.com.cn/是wsdl中definitions根节点的targetNamespace属性
// webservice路径
// 这里后面加不加 "?wsdl" 效果都一样的
String endpoint = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl";
String[] res = null; // 查询城市天气的接口方法名
String operationName = "getWeather";
// 定义service对象
Service service = new Service();
// 创建一个call对象
Call call = (Call) service.createCall();
// 设置目标地址,即webservice路径
call.setTargetEndpointAddress(endpoint);
// 设置操作名称,即方法名称
call.setOperationName(new QName("http://WebXml.com.cn/", operationName));
// 设置方法参数
call.addParameter(new QName("http://WebXml.com.cn/", "theCityCode"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://WebXml.com.cn/", "theUserID"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
// 设置返回值类型
// 对于返回是字符串数组的返回类型只有这两种可行 // call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_VECTOR);
call.setReturnClass(java.lang.String[].class); call.setUseSOAPAction(true);
call.setSOAPActionURI("http://WebXml.com.cn/" + "getWeather"); res = (String[]) call.invoke(new Object[] { cityCode, userId }); // 如果返回类型是org.apache.axis.encoding.XMLType.SOAP_VECTOR时用下面的转型接收
// Vector v=(Vector) call.invoke(new Object[]{cityCode,userId});
for (String str : res) {
System.out.println(str);
}
}
}

7.Web Service 调用天气代码的更多相关文章

  1. IGS_学习笔记07_IREP通过页面测试客户化Web Service调用(案例)

    20150819 Created By BaoXinjian

  2. IGS_学习笔记08_IREP通过soapUI测试客户化Web Service调用(案例)

    20150819 Created By BaoXinjian

  3. 翻译-使用Spring调用SOAP Web Service

    原文链接: http://spring.io/guides/gs/consuming-web-service/ 调用SOAP web service 本指南将指导你使用Spring调用一个基于SOAP ...

  4. C#使用SOAP调用Web Service

    程序代码 using System;using System.IO;using System.Net;using System.Text; namespace ConsoleApplication1{ ...

  5. C#开发和调用Web Service

    http://blog.csdn.net/h0322/article/details/4776819 1.1.Web Service基本概念 Web Service也叫XML Web Service ...

  6. ASP.NET调用Web Service

    1.1.Web Service基本概念 Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求, ...

  7. C# 调用 Web Service

    Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求,轻量级的独立的通讯技术.是:通过SOAP ...

  8. 如何使用 JMeter 调用你的 Restful Web Service?进行简单的压力测试和自动化测试

    表述性状态传输(REST)作为对基于 SOAP 和 Web 服务描述语言(WSDL)的 Web 服务的简单替代,在 Web 开发上得到了广泛的接受.能够充分证明这点的是主流 Web 2.0 服务提供商 ...

  9. .Net调用Java端带有WS-Security支持的Web Service各方案实战【转】

    原文:http://www.xuebuyuan.com/641669.html 到现在为止,我们AEP平台已经发布很长一段时间了,也有很多ISV接入并上线了,就语言而言,目前主要有三类:Java..N ...

随机推荐

  1. java9新特性-2-安装与官网说明

    1.jdk 9的下载 http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html         下载安 ...

  2. TrueOS 不再想要成为“桌面 BSD”了

    作者: John Paul Wohlscheid 译者: LCTT geekpi | 2018-07-13 22:53 TrueOS 很快会有一些非常重大的变化.今天,我们将了解桌面 BSD 领域将会 ...

  3. GIL解释锁及进程池和线程池

    官方介绍 ''' 定义: In CPython, the global interpreter lock, or GIL, is a mutex that prevents multiple nati ...

  4. [洛谷P1343]地震逃生

    题目大意:有n个点m条单向边,每条边有一个容量.现有x人要分批从1走到n,问每批最多能走多少人,分几批运完(或输出无法运完). 解题思路:一看就是网络流的题目.每批最多能走多少人,即最大流.分几批运完 ...

  5. 紫书 例题 10-8 UVa 1262 (暴力枚举)

    递归一遍遍历所有情况就ok了 #include<cstdio> #include<cstring> #define REP(i, a, b) for(int i = (a); ...

  6. fork函数详解

    一.fork入门知识 一个进程,包括代码.数据和分配给进程的资源.fork()函数通过系统调用创建一个与原来进程几乎完全相同的进程,也就是两个进程可以做完全相同的事,但如果初始参数或者传入的变量不同, ...

  7. 【计算机视觉】基于Kalman滤波器的进行物体的跟踪

    预估器 我们希望能够最大限度地使用測量结果来预计移动物体的运动. 所以,多个測量的累积能够让我们检測出不受噪声影响的部分观測轨迹. 一个关键的附加要素即此移动物体运动的模型. 有了这个模型,我们不仅能 ...

  8. java内部类的初始化

    public class InnerClassTest { /** * @param args */ public static void main(String[] args) { // TODO  ...

  9. .ds_store是什么文件

    .ds_store是什么文件 .DS_Store是Mac OS保存文件夹的自定义属性的隐藏文件,如文件的图标位置或背景色,相当于Windows的desktop.ini. 1,禁止.DS_store生成 ...

  10. 实测Untangle - Linux下的安全网关

    UntangleGateway是一个Linux下开源的的网关模块,支持垃圾过滤.URL阻截.反病毒蠕虫等多种功能,其实他的功能还远不止这些,经过一段时间研究本人特制作本视频供大家参考. 本文出自 &q ...