导包
antlr-2.7.7.jar
aopalliance-1.0.jar
asm-3.3.jar
commons-collections-3.2.1.jar
commons-lang-2.6.jar
commons-logging-1.1.1.jar
cxf-2.4.2.jar
cxf-manifest.jar
cxf-xjc-boolean-2.4.0.jar
cxf-xjc-bug671-2.4.0.jar
cxf-xjc-dv-2.4.0.jar
cxf-xjc-ts-2.4.0.jar
FastInfoset-1.2.9.jar
geronimo-activation_1.1_spec-1.1.jar
geronimo-annotation_1.0_spec-1.1.1.jar
geronimo-javamail_1.4_spec-1.7.1.jar
geronimo-jaxws_2.2_spec-1.0.jar
geronimo-jms_1.1_spec-1.1.1.jar
geronimo-servlet_3.0_spec-1.0.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
geronimo-ws-metadata_2.0_spec-1.1.3.jar
isorelax-20030108.jar
jaxb-api-2.2.1.jar
jaxb-impl-2.2.1.1.jar
jaxb-xjc-2.2.1.1.jar
jettison-1.3.jar
jetty-continuation-7.4.5.v20110725.jar
jetty-http-7.4.5.v20110725.jar
jetty-io-7.4.5.v20110725.jar
jetty-security-7.4.5.v20110725.jar
jetty-server-7.4.5.v20110725.jar
jetty-util-7.4.5.v20110725.jar
joda-time-1.6.2.jar
jra-1.0-alpha-4.jar
js-1.7R2.jar
jsr311-api-1.1.1.jar
msv-core-2010.2.jar
neethi-3.0.1.jar
opensaml-2.4.1.jar
openws-1.4.1.jar
relaxngDatatype-20020414.jar
saaj-api-1.3.jar
saaj-impl-1.3.2.jar
serializer-2.7.1.jar
slf4j-api-1.6.1.jar
slf4j-jdk14-1.6.1.jar
spring-aop-3.0.5.RELEASE.jar
spring-asm-3.0.5.RELEASE.jar
spring-beans-3.0.5.RELEASE.jar
spring-context-3.0.5.RELEASE.jar
spring-core-3.0.5.RELEASE.jar
spring-expression-3.0.5.RELEASE.jar
spring-jms-3.0.5.RELEASE.jar
spring-tx-3.0.5.RELEASE.jar
spring-web-3.0.5.RELEASE.jar
stax2-api-3.1.1.jar
velocity-1.7.jar
woodstox-core-asl-4.1.1.jar
wsdl4j-1.6.2.jar
wss4j-1.6.2.jar
xalan-2.7.1.jar
xml-resolver-1.2.jar
xmlbeans-2.4.0.jar
xmlschema-core-2.0.jar
xmlsec-1.4.5.jar
xmltooling-1.3.1.jar
xsdlib-2010.1.jar
使用父类发布服务
ServerFactoryBean 发布 webservice
package cn.itcast.cxf; import org.apache.cxf.frontend.ServerFactoryBean; /**
* 使用ServerFactoryBean发布CXF的javase应用
* @author
*
*/
public class HelloService { public String sayHello(String name){
System.out.println("sayHello called...");
return "hello " + name;
} public static void main(String[] args) {
//获得服务工厂bean
ServerFactoryBean bean = new ServerFactoryBean();
//绑定服务的发布地址
bean.setAddress("http://192.168.151.42:5678/hello");
//指定提供服务的类型
bean.setServiceClass(HelloService.class);
//指定提供服务的实例
bean.setServiceBean(new HelloService());
//启动服务-----publish
bean.create();
System.out.println("server ready...");
}
}
使用子类发布服务
JaxWsServerFactoryBean 类发布 cxf javase webservice应用
package cn.itcast.cxf; import javax.jws.WebService;
import javax.jws.soap.SOAPBinding; import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.apache.cxf.wsdl.http.BindingType; /**
* 使用JaxWsServerFactoryBean发布CXF的javase应用
* 必须要在被发布为服务的类上添加@WebService注解,如果不加注解,虽然不
出错,但也不会对外暴露任何方法
* @author zhaoqx
*
*/
@WebService
//将服务端改成soap 1.2版本,不加的话发布的是1.1版本的
@javax.xml.ws.BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
public class HiService {
public String sayHi(String name){
System.out.println("sayHi called...");
return "hi " + name;
} public static void main(String[] args) {
JaxWsServerFactoryBean bean = new JaxWsServerFactoryBean();
bean.setAddress("http://192.168.151.42:6789/hi");
bean.setServiceClass(HiService.class);
bean.setServiceBean(new HiService());
bean.create();
System.out.println("server ready...");
}
}