`
wtnhwbb
  • 浏览: 164174 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

axis java 调用 .net Web Services

阅读更多
/**
	 * QQ在线状态查询
	 */
	public static void main(String[] args) {
		//设置代理
		System.getProperties().put("proxySet", "true");
		System.getProperties().put("proxyHost", "192.168.0.26");
		System.getProperties().put("proxyPort", "808");
		//设置socket代码
		System.getProperties().put("socksProxySet", "true");
		System.getProperties().put("socksProxyHost", "192.168.0.26");
		System.getProperties().put("socksProxyPort", "1080");
		try {
			//WebServices服务地址
			String endpoint = "http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx";
			Service service = new Service();
			Call call = (Call) service.createCall();
			call.setTargetEndpointAddress(new java.net.URL(endpoint));

			//要调用的方法名
			call.setOperationName("qqCheckOnline");
			//设置调用方法参数
			call.addParameter(new javax.xml.namespace.QName("http://WebXml.com.cn/",
					"qqCode"), org.apache.axis.encoding.XMLType.XSD_STRING, String.class,
					javax.xml.rpc.ParameterMode.IN);

			//设置返回类型
			call.setReturnClass(String.class);
			/** 
			//new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema"
			//, "string")或org.apache.axis.encoding.XMLType.XSD_STRING都可以
			//设置返回类型
			call.setReturnType(new javax.xml.namespace.QName(
					"http://www.w3.org/2001/XMLSchema", "string"));
			//返回参数名
			call.setReturnQName(new javax.xml.namespace.QName(
					"http://WebXml.com.cn/", "qqCheckOnlineResult"));
					**/
			
			call.setUseSOAPAction(true);
			call.setSOAPActionURI("http://WebXml.com.cn/qqCheckOnline");

			//http://WebXml.com.cn/ 命名空间
			call.setOperationName(new javax.xml.namespace.QName(
					"http://WebXml.com.cn/", "qqCheckOnline"));

			String k = (String) call.invoke(new Object[] { "285336157" });
			System.out.println("result is " + k.toString() + ".");
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
 
分享到:
评论
2 楼 xueqing227 2010-06-12  
非常感谢。帮我解决了一个大问题。
1 楼 smallboby 2010-02-01  
很好。很强大。。试了下可以。

相关推荐

Global site tag (gtag.js) - Google Analytics