`
- 浏览:
35785 次
- 性别:
- 来自:
深圳
-
axis调用中国气象局web服务,用dom4j解析的例子
- package service.cilent;
-
- import java.util.Iterator;
- import org.apache.axiom.om.OMAbstractFactory;
- import org.apache.axiom.om.OMElement;
- import org.apache.axiom.om.OMFactory;
- import org.apache.axiom.om.OMNamespace;
- import org.apache.axiom.soap.SOAP11Constants;
- import org.apache.axis2.Constants;
- import org.apache.axis2.addressing.EndpointReference;
- import org.apache.axis2.client.Options;
- import org.apache.axis2.client.ServiceClient;
- import org.apache.axis2.transport.http.HttpTransportProperties.ProxyProperties;
- import org.dom4j.Document;
- import org.dom4j.DocumentHelper;
- import org.dom4j.Element;
-
-
- public class JavaServicesClient {
- private static EndpointReference targetEPR = new EndpointReference("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx");
-
- @SuppressWarnings("unchecked")
- public void getResult() throws Exception {
- ServiceClient sender = new ServiceClient();
- sender.setOptions(buildOptions());
-
- OMElement result = sender.sendReceive(buildParam());
-
- Document doc = DocumentHelper.parseText(result.toString());
-
- Element rootElt = doc.getRootElement();
-
- Iterator iter = rootElt.elementIterator("getWeatherbyCityNameResult");
- while(iter.hasNext()){
- Element recordEle = (Element) iter.next();
-
- Iterator iters = recordEle.elementIterator("string");
- while(iters.hasNext()){
- Element itemEle = (Element) iters.next();
-
- System.out.println(itemEle.getTextTrim());
- }
- }
- }
-
- 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.setTransportInProtocol(Constants.TRANSPORT_HTTP);
- return options;
- }
-
-
-
-
-
-
- public static ProxyProperties buildProxy() {
- ProxyProperties proxyProperties = new ProxyProperties();
- proxyProperties.setProxyName("代理名称");
- proxyProperties.setProxyPort(8080);
- return proxyProperties;
- }
-
- public static void main(String[] args) throws Exception {
- JavaServicesClient s = new JavaServicesClient();
- s.getResult();
- }
- }
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
axis2客户端调用axis1服务接口 调用方式 使用RPC方式调用WebService,为了防止冲突可以增加 // 与weblogic的lib冲突配置 System.setProperty("javax.xml.stream.XMLInputFactory", ...
使用Java+Axis2调用Web Services 网络接口,代码中列举4个例子可以查看,有详细注释提供参考。
使用Axis发补调用服务。对于初学者用帮助!
axis调用第三方webservice接口所需的jar包,包括axis-1.4.jar,axis-jaxrpc-1.3.jar,axis-jaxrpc-1.4.jar,commons-discovery-0.5.jar,commons-logging-1.2.jar,cxf-rt-databinding-jaxb-3.3.1.jar,javax.mail-...
用框架cxf调用axis2提供的接口服务的一个简单例子,
本案例实现使用Axis2生成.arr包发布WebService服务,并使用Axis2生成客户端代码方式调用WebService
<groupId>org.apache.axis2 <artifactId>axis2 <version>1.6.2 <groupId>org.apache.axis2 <artifactId>axis2-adb <version>1.6.2 <groupId>org.apache.axis2 ...
Android 利用axis2 调用webservice 包含j2ee服务端代码和Android客户端代码 代码实现包含 List,map ,对象传递
单位刚好有这么一个项目需要于客户端中调用webServices,整理了下资料发上来希望对大家有用。 axis 1.4 一共是三种方式调用: 1传递参数String,得到String 2传递参数String,得到对象Users 3传递对象Users,得到...
axis2 开发 axis webservice web 服务
本系统通过分析web服务调用过程总的若干步骤以及联系,采用WSDL4J分析用户提供的WSDL文件,解析出所有的服务操作以及操作所使用的数据类型的数据结构,同时解析出相应操作的访问入口点为以后调用服务提供依据。...
基于 Apache Axis2 将上述类的方法对外提供 Web 服务,生成 WSDL 文件,以及调用 服务 2019-12-23根据全网的教程搭建最详细的教程 源码太大上传不了,但是教程内容十分详细,跟着我的教程一步一步就可以搭建起来,...
axis2客户端,调用带ntlm认证的web service的代码例子和所需jar和java
java axis 调用C# webService所需的jar包
客户端用axis调用webservice实例 里面包含所需的jar包,希望对大家有用(不好意思,赚点积分啊)
java axis客户端调用webservice,可应用于ofbiz框架。 解决网络上共享代码两次调用后会出现timeout的BUG
压缩包中包含详细代码以及所用到的jar,是完整可运行的project。当然,需要正确的路径支持才可以运行,本人没有把我所用到的路径贴出,改为本机地址。
axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例axis2例子 webservice axis2 示例
java基于Axis2调用C#开发的web service获取xml结果
使用myeclipse8.5安装axis2插件,工程主要是通过server端类生成服务,生成客户端。 1、使用服务端类com.Hello.java,com.Other.java生成wsdl、aar文件【aar文件通过axis2插件的Axis2 service archiver生成】【wsdl...