在 Spring 配置文件中导入 CXF 提供 Schema、XML 详情
2016-10-28 23:51
609 查看
3 . 在 Spring 配置文件中导入 CXF 提供 Schema、XML(cxf.jar 包里提供)
* Schema 文件
<beans xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://cxf.apache.org/jaxws //命名空间
http://cxf.apache.org/schemas/jaxws.xsd">//物理路径
* XML 的配置文件
[b] <import resource="classpath:META-INF/cxf/cxf.xml"/>
[b] <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>[/b]
[/b]
* 下面是一个简单的xml配置文件,我们来分析如何导入 CXF 提供 Schema、XML
* 在 Spring 配置文件中导入 CXF 提供 Schema 文件,在 cxf.jar 包里提供:
导入效果:
* 导入 CXF 的 XML 文件:
导入效果:
修改正确 XML 的导入路径即可!
希望对你有帮助,祝你有一个好心情,加油!
若有错误、不全、可优化的点,欢迎纠正与补充;转载请注明出处!
* Schema 文件
<beans xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://cxf.apache.org/jaxws //命名空间
http://cxf.apache.org/schemas/jaxws.xsd">//物理路径
* XML 的配置文件
[b] <import resource="classpath:META-INF/cxf/cxf.xml"/>
[b] <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>[/b]
[/b]
* 下面是一个简单的xml配置文件,我们来分析如何导入 CXF 提供 Schema、XML
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- Web应用的类加载路径有两类 1.WEB-INF/classes目录 2.WEB-INF/lib目录下 --> <import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> <!-- 注册Service --> <bean id="userService" class="org.fjava.cxf.service.UserServiceImpl"/> <bean id="helloWorldWs" class="org.fjava.cxf.ws.impl.HelloWorldWs" p:userService-ref="userService"/> <!-- implementor指定WebService的服务提供者 1.直接给定服务器提供者类名 2.设置为容器中的Bean,要在Bean的id前加上#号 --> <jaxws:endpoint implementor="#helloWorldWs" address="/getAllFoods"> <!-- 添加了两个In拦截器 --> <jaxws:inInterceptors> <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/><!-- 嵌套Bean,创建一个Bean --> <bean class="org.fjava.cxf.ws.auth.AuthInterceptor"/> <!-- <ref bean="anotherInterceptor">引用一个已有的Bean --> </jaxws:inInterceptors> <!-- 需要配置Out拦截器,使用<jaxws:outInterceptors> --> </jaxws:endpoint> <!-- <jaxws:endpoint implementor="org.fjava.cxf.ws.impl.HelloWorldWs" address="/getAllFoods"> </jaxws:endpoint> --> </beans>
* 在 Spring 配置文件中导入 CXF 提供 Schema 文件,在 cxf.jar 包里提供:
导入效果:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
* 导入 CXF 的 XML 文件:
导入效果:
<import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>若导入 XML 文件错误,运行服务端报错:
十月 28, 2016 11:40:53 下午 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/cxf/cxff.xml] Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/cxf/cxff.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/cxf/cxff.xml] cannot be opened because it does not exist at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/cxf/cxff.xml]
修改正确 XML 的导入路径即可!
希望对你有帮助,祝你有一个好心情,加油!
若有错误、不全、可优化的点,欢迎纠正与补充;转载请注明出处!
相关文章推荐
- 在 Spring 配置文件中导入 CXF 提供 Schema、XML 详情
- 在 Spring 配置文件中导入 CXF 提供 Schema、XML 详情
- 关于Spring配置文件xml文档的schema约束
- Spring主配置文件导入约束(applicationContext.xml)
- Spring的配置文件xml中报错:xml文件报错Referenced file contains errors (http://www.springframework.org/schema/cont
- spring配置文件xml文件开头总是有个红叉,是找不到schema文件
- Spring整合了CXF的一个applicationContext.xml的配置文件
- CXF与SPRING的无缝整合时,为什么不用写CXF的配置文件cxf-servlet.xml?
- 基于Spring可扩展Schema提供自定义配置支持(spring配置文件中 配置标签支持)
- Spring学习----- Spring配置文件xml文档的schema约束
- 基于Spring可扩展Schema提供自定义配置支持(spring配置文件中 配置标签支持)
- 基于Spring可扩展Schema提供自定义配置支持(spring配置文件中 配置标签支持)
- 基于Spring可扩展Schema提供自定义配置支持(spring配置文件中 配置标签支持)
- 关于Spring配置文件xml文档的schema约束
- 基于Spring可扩展Schema提供自定义配置支持(spring配置文件中 配置标签支持)
- 基于Spring可扩展Schema提供自定义配置支持(spring配置文件中 配置标签支持)
- Dubbo源码分析(三):自定义Schema--基于Spring可扩展Schema提供自定义配置支持(spring配置文件中 配置标签支持)
- 基于Spring可扩展Schema提供自定义配置支持(spring配置文件中 配置标签支持)
- 基于Spring可扩展Schema提供自定义配置支持(spring配置文件中 配置标签支持)
- Spring 配置文件xml文档的schema约束