基本信息
源码名称:java调用 webservice 实例
源码大小:0.27M
文件格式:.rar
开发语言:Java
更新时间:2015-09-09
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
package ws;
import java.net.MalformedURLException;
import java.net.URL;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.Client;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
public class HelloClient {
public static void main(String[] args) {
Service s = new ObjectServiceFactory().create(IHello.class);
XFireProxyFactory xf = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
String url="http://localhost:8080/webService/services/HelloService";
IHello hello;
try {
hello = (IHello)xf.create(s, url);
System.out.println(hello.sayHello("你好"));
} catch (MalformedURLException e) {
e.printStackTrace();
}
// try {
// //这个是在java端调用.net写的远程Web Service 如果调用本机写的只需要把URL中的地址换成本机能访问的地址即可
// Client c = new Client(new URL("http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl"));
// Object[] o = c.invoke("qqCheckOnline", new String[]{"271751507"});
// System.out.println(o.length);
// } catch (Exception e) {
// e.printStackTrace();
// }
}
}