<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="org.apache.axiom.om.OMAbstractFactory"%>
<%@ page import="org.apache.axiom.om.OMElement"%>
<%@ page import="org.apache.axiom.om.OMFactory"%>
<%@ page import="org.apache.axiom.om.OMNamespace"%>
<%@ page import="org.apache.axiom.soap.SOAP11Constants"%>
<%@ page import="org.apache.axis2.AxisFault"%>
<%@ page import="org.apache.axis2.Constants"%>
<%@ page import="org.apache.axis2.addressing.EndpointReference"%>
<%@ page import="org.apache.axis2.client.Options"%>
<%@ page import="org.apache.axis2.client.ServiceClient"%>
<%!
private static EndpointReference targetEPR = new EndpointReference(
"http://www.webxml.com.cn/WebServices/WeatherWebService.asmx");
public void getResult() throws Exception {
ServiceClient sender = new ServiceClient();
sender.setOptions(buildOptions());
OMElement result = sender.sendReceive(buildParam());
System.out.println(result);
}
private static OMElement buildParam() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://WebXml.com.cn/", "");
OMElement data = fac.createOMElement("getWeatherbyCityName", omNs);
OMElement inner = fac.createOMElement("theCityName", omNs);
inner.setText("成都");
data.addChild(inner);
return data;
}
private static Options buildOptions() {
Options options = new Options();
options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setAction("http://WebXml.com.cn/getWeatherbyCityName");
options.setTo(targetEPR);
// options.setProperty 如果不是通过代理上网,此句可省
// options.setProperty(HTTPConstants.PROXY, buildProxy());
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
return options;
}
%>
<%
getResult();
%>
分享到:
相关推荐
本代码使用AXIS2客户端调用,用WSDL2JAVA 生成代码,解决DATASET类型不兼容问题.
这是我在myeclipse中用axis2使用网上提供的天气预报服务的简单demo。你可以在普通的java类中,直接将该代码复制过去即可,当然不要忘了导入axis的jar包。axis的jar包和网上的web service地址,在我的资源和博客中都...
NULL 博文链接:https://chen106106.iteye.com/blog/1069463
NULL 博文链接:https://topmanopensource.iteye.com/blog/423897
天气预报WEB服务JAVA实例 axis1.4 天气预报WEB服务JAVA实例使用接口:2400多个城市5日天气预报 WEB服务Endpoint: ...
调用天气预报webService axis1.4
axis2请求.Net webservice接口,以天气预报getSupportCity接口为例
根据天气预报webservice的wsdl解析成本地的Java代码;用Java代码调用webservice天气...本资源已用axis将webservice的wsdl解析成本地的Java代码,并实现Java代码调用天气预报;现将其打包上传,望对有需要的人有所帮助!
NULL 博文链接:https://luogen33.iteye.com/blog/1684266
webservice通信调用天气预报接口实例,所使用到的工具
用eclipse做的天气预报插件,稍微有一点问题,就是当作为插件运行的时候,总是出不来,不过你可以当Java application运行,一点儿问题都没有。关键在于里面运用的技术:webservice,我用Axis2实现的。
WebService天气预报接口所需要的jar,其中mail.jar与activation.jar 希望对大家有帮组啊!还有apache的第一代webservice开发工具,在官方找了一阵,没找着,大家免费下载!
关于天气预报的web服务服务端远代码,用java语言编写的,axis开发工具
项目使用webservice的方式调用了中央气象局的气象接口,该demo可以满足工作或学习中的大部分需求。
2个目标文件,FTP的目标是:(1)提高文件的共享性(计算机程序和/或数据),(2)鼓励间接地(通过程序)使用远程计算机,(3)保护用户因主机之间的文件存储系统导致的变化,(4)为了可靠和高效地传输,虽然用户...
2个目标文件,FTP的目标是:(1)提高文件的共享性(计算机程序和/或数据),(2)鼓励间接地(通过程序)使用远程计算机,(3)保护用户因主机之间的文件存储系统导致的变化,(4)为了可靠和高效地传输,虽然用户...