Axis2调用C#写的WebService(转自网易http://blog.163.com/cjd_cd/blog/static/46115565200811239239831/)
来源:互联网 发布:守望先锋数据查询关闭 编辑:程序博客网 时间:2024/05/13 01:19
axis2 天气预报 调用.net的webservice
webservice 2008-12-23 21:02:39 阅读315 评论0 字号:大中小 订阅
package com.axisweather.test;
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;
// http://hi.baidu.com/e_ville/blog/item/f6529fa1a6616a8e471064a3.html
/**
* 测试WebService
* @author
* @history 2008-4-16
*/
public class ServiceGetWeather {
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(propertyKey, property)
// enabling MTOM in the client side
// options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
return options;
}
public static void main(String[] args) throws Exception {
ServiceGetWeather s = new ServiceGetWeather();
s.getResult();
}
}
- Axis2调用C#写的WebService(转自网易http://blog.163.com/cjd_cd/blog/static/46115565200811239239831/)
- 转自:http://rongjih.blog.163.com/blog/static/33574461201247102329705/
- EJB的远程调用与本地调用http://fay19860916.blog.163.com/blog/static/1186491192009819220664/
- linux下screen用法详解[转自http://sirius.gnu.blog.163.com/blog/static/146833680201062232256461/]
- Apache反向代理配置(转自http://ruijunsuo.blog.163.com/blog/static/400596322011274914990/)
- 索引(转自http://blog.163.com/owx8012@126/blog/static/3844624620099152102133/)
- GCC 中的inline关键字 转自:http://xushouze2006.blog.163.com/blog/static/16230032200831710196672/
- QT类继承图(转自:http://blog.163.com/sxs_solo/blog/static/263333820086410169909/)
- openCV 转自(http://zhang-jh04.blog.163.com/blog/static/97487172200962092332160/)
- fckeditor的用法,如何获得编辑器中的内容(转自http://suichunyu1987.blog.163.com/blog/static/87309653200981032351210/)
- N种内核注入DLL的思路及实现(转自http://devil209.blog.163.com/blog/static/50820980201041391645319/)
- 漂亮的网页文字颜色(转自http://solo.mon2.blog.163.com/blog/static/6250987020103711438318/)
- 在eclipse中实现代码的自动换行 转自:http://liangfangli86.blog.163.com/blog/static/9684863120116183727729/
- [转]开源软件是怎样赚钱的 - txfast的日志 - 网易博客 http://txfast.blog.163.com/blog/static/40536042200822742226361/
- ext的grid导出为excel 方法(转http://leoni236.blog.163.com/blog/static/4814624920109892520226/)
- 我的网易博客地址http://hgq52111314.blog.163.com
- 我的网易博客http://wmzjzwlzs.blog.163.com/
- 我的网易博客http://wmzjzwlzs.blog.163.com/
- Warning - bad CRC, using default environment
- sqlite3的C代码操作
- B2B,B2C,C2C,C2B,M2C,I2C之间的区别
- (转)C++中extern “C”含义深层探索
- (转)C++中extern “C”含义深层探索
- Axis2调用C#写的WebService(转自网易http://blog.163.com/cjd_cd/blog/static/46115565200811239239831/)
- 委托和事件
- WEBrick在局域网内响应慢的解决方案
- 相对静态的链表实现
- 整理笔记
- 用PHP的OB_START();控制您的浏览器CACHE
- 图论,割点求法
- void man,心碎真的很好听!
- html css 的常用