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. P1452 Beauty Contes

    题目背景 此处省略1W字^ ^ 题目描述 贝茜在牛的选美比赛中赢得了冠军”牛世界小姐”.因此,贝西会参观N(2 < = N < = 50000)个农场来传播善意.世界将被表示成一个二维平面 ...

  2. PostgreSQL Replication之第八章 与pgbouncer一起工作(4)

    8.4 提升性能 从一开始考虑pgbouncer的时候,性能就是一个关键的因素.为了确保高性能,有些问题必须认真对待.首先,确保参与您设置的所有节点相互之间的距离较近.这对于降低网络往返时间有很多的帮 ...

  3. <Sicily> Longest Common Subsequence

    一.题目描述 Given a sequence A = < a1, a2, -, am >, let sequence B = < b1, b2, -, bk > be a s ...

  4. SQL--去除字符串空格、截取字符串

  5. [国家集训队]整数的lqp拆分 数学推导 打表找规律

    题解: 考场上靠打表找规律切的题,不过严谨的数学推导才是本题精妙所在:求:$\sum\prod_{i=1}^{m}F_{a{i}}$ 设 $f(i)$ 为 $N=i$ 时的答案,$F_{i}$ 为斐波 ...

  6. Python实现快排

    Python实现快排 def quicksort(arr): if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] left = [x ...

  7. 利用NSProxy解决NSTimer内存泄漏问题

    之前写过一篇利用RunTime解决由NSTimer导致的内存泄漏的文章,最近和同事讨论觉得这样写有点复杂,然后发现有NSProxy这么好用的根类,根类,根类,没错NSProxy与NSObject一样是 ...

  8. Oracle EBS发放销售订单

     模拟发放销售订单界面进行发放操作 PROCEDURE insert_row(x_batch_id OUT NUMBER) IS l_autopack_flag VARCHAR2(1 ); l_a ...

  9. To new is C++; To malloc is C; To mix them is sin (混淆C++中的new和C中的malloc是一种犯罪)

    Introduction One of the most common questions that get asked during interviews for C++ programmers i ...

  10. 遇到 Form 性能问题怎么办 performance issue

    性能问题是比較复杂的问题. 一般由performance team 负责, 可是常见的情况是, 我们 INV team 定义的 view 不好, 导致查询性能较差. 这个必须由产品组和 perform ...