基于CXF的WebService接口

jar包所需:

cxf-core-3.0.4.jar
cxf-rt-bindings-soap-3.0.4.jar
cxf-rt-databinding-jaxb-3.0.4.jar
cxf-rt-frontend-jaxws-3.0.4.jar
cxf-rt-frontend-simple-3.0.4.jar
cxf-rt-transports-http-3.0.4.jar
cxf-rt-transports-udp-3.0.4.jar
cxf-rt-ws-addr-3.0.4.jar
cxf-rt-wsdl-3.0.4.jar
cxf-rt-ws-policy-3.0.4.jar
cxf-rt-wsdl-3.0.4.jar
neethi-3.0.3.jar
slf4j-api-1.7.9.jar
xmlschema-core-2.2.1.jar

网上找到的部分jar缺失报错的

1、org.apache.catalina.LifecycleException: A child container failed during start
缺少:cxf-core-3.0.4.jar(最核心的包,不多说)


2、java.lang.ClassNotFoundException: org.apache.cxf.binding.soap.SoapBindingConfiguration
缺少:cxf-rt-bindings-soap-3.0.4.jar       (soap协议)
 

3、org.apache.cxf.jaxb.JAXBDataBinding:
缺少:cxf-rt-databinding-jaxb-3.0.4.jar      


4、加载Application文件时出现Unable to locate Spring NamespaceHandler for XML schema namespace
     [http://cxf.apache.org/jaxws]

缺少:cxf-rt-frontend-jaxws-3.0.4.jar    (frontend 前置的意思,你懂的)

5、org/apache/cxf/frontend/spring/ClientProxyFactoryBeanDefinitionParser错误:
缺少:cxf-rt-frontend-simple-3.0.4.jar


6、class path resource [META-INF/cxf/cxf-servlet.xml] cannot be opened because it does not exist
缺少:cxf-rt-transports-http-3.0.4.jar


7、org.apache.cxf.BusException: No DestinationFactory was found for the namespace http://cxf.apache.org/transports/udp.
缺少:cxf-rt-transports-udp-3.0.4.jar


8、org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl startup
警告: Could not start WS-Discovery Service.
javax.xml.ws.WebServiceException: java.lang.NullPointerException
不能初始化配置的bean服务,也就是运行到<jaxws:server>时出错

缺少:cxf-rt-ws-addr-3.0.4.jar

9、java.lang.ClassNotFoundException: org.apache.cxf.ws.policy.AssertionInfoMap
缺少:cxf-rt-ws-policy-3.0.4.jar        


10、java.lang.ClassNotFoundException: org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean
缺少:cxf-rt-wsdl-3.0.4.jar

11、java.lang.ClassNotFoundException: org.apache.neethi.AssertionBuilderFactory
缺少:neethi-3.0.3.jar

12、java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
缺少:slf4j-api-1.7.9.jar

13、java.lang.ClassNotFoundException: org.apache.ws.commons.schema.resolver.URIResolver
缺少:xmlschema-core-2.2.1.jar

 

1、web.xml中添加cxf的servlet

  <servlet>
    <servlet-name>CXFServlet</servlet-name>
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/service/*</url-pattern>
  </servlet-mapping>
  <servlet>

2、创建接口

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public interface syncManufacturer {
	@WebMethod(operationName="syncManufacturer")
	public String syncManufacturer(String xml);
}

3、创建接口实现类

import org.springframework.stereotype.Service;
import javax.jws.WebMethod;

@Service
public class syncManufacturerImpl implements syncManufacturer {
	
	@WebMethod(operationName="syncManufacturer")
	public String syncManufacturer(String xml) {
        //报文解析,代码逻辑块等

        }

}

 

4、applicationContext.xml 

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
	xmlns:cxf="http://cxf.apache.org/core"
	xsi:schemaLocation="
	http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
	http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
	http://cxf.apache.org/jaxws
	http://cxf.apache.org/schemas/jaxws.xsd">

jaxws:endpoint中 implementor是因为接口实现使用的是@Service注解所以不需要写全路径,如果使用@WebService注解则需写全路径

 <bean id="syncManufacturerImpl" class="com.acconsys.alms.smManufacturer.webService.impl.syncManufacturerImpl">
    	<property name="syncManufacturerService" ref="syncManufacturerService" />
    </bean>
    
	<jaxws:endpoint id="syncManufacturer" implementor="#syncManufacturerImpl" address="/syncManufacturer">
	</jaxws:endpoint>

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值