[JAVA]使用axis调用.NET写的WebService_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > [JAVA]使用axis调用.NET写的WebService

[JAVA]使用axis调用.NET写的WebService

 2011/12/22 9:22:15  leon1509  http://leon1509.iteye.com  我要评论(0)
  • 摘要:参考:http://wenwen.soso.com/z/q165150846.htm?sp=1133直接上代码,本例只调用了WebService的getRegionCountry方法:importjava.rmi.RemoteException;importjavax.xml.rpc.ServiceException;importorg.apache.axis.client.Call;importorg.apache.axis.client.Service;publicclassTestWS
  • 标签:.net Web Service 使用 net Webservice Java
参考:http://wenwen.soso.com/z/q165150846.htm?sp=1133

直接上代码,本例只调用了WebService的getRegionCountry方法:

import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class TestWS {
	public static void main(String[] args) throws RemoteException,
			ServiceException {
		String endPoint = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx";
		Service service = new Service();
		Call call = (Call) service.createCall();
		call.setTargetEndpointAddress(endPoint);
		call.setReturnClass(java.lang.String[].class);
		
		String oName = "getRegionCountry";
		call.setUseSOAPAction(true);
		call.setSOAPActionURI("http://WebXml.com.cn/" + oName);

		call.setOperationName(oName);

//		call.addParameter("theCityCode", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
//		call.addParameter("theUserID", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
//		String[] results = (String[]) call.invoke(new Object[]{"", ""});

		String[] results = (String[]) call.invoke(new Object[] {});

		for (String c : results) {
			System.out.println(c);
		}
	}
}


返回结果:
阿尔及利亚,3320
阿根廷,3522
阿曼,3170
阿塞拜疆,3176
埃及,3317
埃塞俄比亚,3314
爱尔兰,3246
奥地利,3237
澳大利亚,368
巴基斯坦,3169
巴西,3580
保加利亚,3232
比利时,3243
波兰,3235
朝鲜,3163
丹麦,3245
德国,3238
俄罗斯,3225
法国,3241
菲律宾,3151
芬兰,3248
刚果(金),3377
哥伦比亚,3524
古巴,344
韩国,3162
荷兰,3244
加拿大,347
加纳,3313
柬埔寨,3154
捷克,3236
克罗地亚,3233
肯尼亚,3316
拉托维亚,3228
老挝,3155
立陶宛,3227
马达加斯加,3312
马尔代夫,3166
马来西亚,3158
马里,3319
美国,346
蒙古,3165
秘鲁,3578
缅甸,3160
莫桑比克,3311
墨西哥,345
南非,3310
尼泊尔,3164
尼日利亚,3379
挪威,3250
葡萄牙,3239
日本,3161
瑞典,3249
瑞士,3242
塞内加尔,3318
沙特阿拉伯,3172
斯里兰卡,3167
泰国,3159
坦桑尼亚,3315
突尼斯,3321
土耳其,3229
委内瑞拉,342
文莱,3153
乌克兰,3226
乌兹别克斯坦,3175
西班牙,3240
希腊,3230
新加坡,3157
新西兰,369
匈牙利,3234
叙利亚,3174
牙买加,343
伊朗,3171
意大利,3231
印度,3168
印度尼西亚,3152
英国,3247
约旦,3173
越南,3156
智利,3523
上一篇: ajax跨域解决方法 下一篇: 本周小结
发表评论
用户名: 匿名