有人可以填写下面代码中缺少的链接吗?
第一种方式:
Web服务接口文件是HappyService.xml。
JaxWSProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getInterceptors().add(new LoggingInInterceptor());
factory.getInterceptors().add(new LoggingOutInterceptor());
//MISSING LINK. Where does HappyService.class come from? I don't have it
factory.setServiceClass(HappyService.class);
factory.setAddress("http://......../happyService");
//Again how do I get HappyService?
HappyService client = (HappyService) factory.create();
第二种方式:
String UrlString = "Your WSDL URL";
String nameSpaceUri = "urn:Foo";
String serviceName = "MyHelloService";
String portName = "HelloIFPort";
URL helloWsdlUrl = new URL(UrlString);
ServiceFactory serviceFactory = ServiceFactory.newInstance();
Service helloService =
serviceFactory.createService(helloWsdlUrl,
new QName(nameSpaceUri, serviceName));
//Where did dynamicproxy.HelloIF come from? This code won't compile as that file does not exist anywhere
dynamicproxy.HelloIF myProxy =
(dynamicproxy.HelloIF)
helloService.getPort(
new QName(nameSpaceUri, portName),
dynamicproxy.HelloIF.class);
System.out.println(myProxy.sayHello("Buzz"));
任何人如果知道这些接口类从何而来以及它们是如何生成的,请告诉我。看起来我执行 Web 服务调用的唯一方法是手动编写 SOAP 请求,但我真的不想这样做,因为它会变得非常大并且容易出错。
有许多工具可以从 WSDL 定义文件生成 Web 服务 Java 类。
你可以尝试JAXB http://jaxb.java.net/,这是执行此任务的标准 Java 工具。
另一种可能性是Axis http://axis.apache.org/axis/,这一个级别更高。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)