使用XFire调用别人的WebService 刚刚接触到这一块的东东,玩了一天了,也没有搞得很明白,只是会调用自己写的,可是怎么调用别人写的呢,高手指点,3q! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://topic.csdn.net/u/20100322/11/8309d6ac-176a-48f5-b106-a6542be250f9.html?24977 public String getCountryCityByIp(String ip) { String connectPoint = "http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx"; Service srvcModel = new ObjectServiceFactory() .create(IpAddressSearchWebService.class); XFireProxyFactory factory = new XFireProxyFactory(); IpAddressSearchWebService srvc; try { srvc = (IpAddressSearchWebService) factory.create(srvcModel, connectPoint); XFireProxy proxy = (XFireProxy) Proxy.getInvocationHandler(srvc); Client client = proxy.getClient(); //client.setProperty("SOAPAction", "http://WebXml.com.cn/getVersionTime"); client.setProperty("SOAPAction", "http://WebXml.com.cn/getCountryCityByIp"); String ipDetail = srvc.getCountryCityByIp(ip); System.out.println(ipDetail); } catch (MalformedURLException e) { e.printStackTrace(); } return null; } client.setProperty("SOAPAction", "http://WebXml.com.cn/getCountryCityByIp");把这个注释不要!然后IpAddressSearchWebService是自定义接口,可查看wdsl 根据别人的wsdl地址产生客户端,直接调用即可 google 地图问题 jsp+花生壳网站发布问题 struts2中页面参数对应action中属性的问题 hibernate怎么样自关联映射?? textarea 换行 急!!! javabean传递参数 请问java有什么比较好的第三方图形开发包? html转化的问题,帮忙 我是初学者!请大家给些建议和例子 JSP中的中文问题,我还是解决不了(快来抢分呀) SAX解析XML丢失数据怎么办? 求一weblogic 10使用的jar包
public String getCountryCityByIp(String ip) {
String connectPoint = "http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx"; Service srvcModel = new ObjectServiceFactory()
.create(IpAddressSearchWebService.class); XFireProxyFactory factory = new XFireProxyFactory();
IpAddressSearchWebService srvc;
try {
srvc = (IpAddressSearchWebService) factory.create(srvcModel,
connectPoint);
XFireProxy proxy = (XFireProxy) Proxy.getInvocationHandler(srvc);
Client client = proxy.getClient();
//client.setProperty("SOAPAction", "http://WebXml.com.cn/getVersionTime");
client.setProperty("SOAPAction", "http://WebXml.com.cn/getCountryCityByIp");
String ipDetail = srvc.getCountryCityByIp(ip);
System.out.println(ipDetail);
} catch (MalformedURLException e) {
e.printStackTrace();
} return null;
}
把这个注释不要!
然后
IpAddressSearchWebService是自定义接口,可查看wdsl