配置 cxf-ws spring bean 文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <!--
cxf-rt-core-2.1.3.jar
cxf-rt-bindings-soap-2.1.3.jar
cxf-rt-transports-http-2.1.3.jar
-->
<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" /> <jaxws:endpoint id="helloWorld" implementor="org.apache.cxf.HelloWorldImpl"
address="/HelloWorld" /> </beans>
1. import
cxf.xml 位于 cxf-rt-core-2.1.3.jar
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:foo="http://cxf.apache.org/configuration/foo"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"/>
<bean id="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor" class="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor"/>
<bean id="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor" class="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor"/>
<bean id="org.apache.cxf.bus.spring.BusExtensionPostProcessor" class="org.apache.cxf.bus.spring.BusExtensionPostProcessor"/> <bean id="org.apache.cxf.resource.ResourceManager" class="org.apache.cxf.bus.resource.ResourceManagerImpl">
<property name="resolvers">
<list>
<bean class="org.apache.cxf.resource.ClasspathResolver"/>
<bean class="org.apache.cxf.resource.ClassLoaderResolver"/>
<bean class="org.apache.cxf.bus.spring.BusApplicationContextResourceResolver"/>
</list>
</property>
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.configuration.Configurer"
class="org.apache.cxf.configuration.spring.ConfigurerImpl">
</bean> <bean id="org.apache.cxf.binding.BindingFactoryManager" class="org.apache.cxf.binding.BindingFactoryManagerImpl">
<property name="mapProvider">
<bean class="org.apache.cxf.configuration.spring.SpringBeanMap">
<property name="type" value="org.apache.cxf.binding.BindingFactory"/>
<property name="idsProperty" value="activationNamespaces"/>
</bean>
</property>
<property name="bus" ref="cxf"/>
</bean> <bean id="org.apache.cxf.transport.DestinationFactoryManager" class="org.apache.cxf.transport.DestinationFactoryManagerImpl">
<property name="mapProvider">
<bean class="org.apache.cxf.configuration.spring.SpringBeanMap">
<property name="type" value="org.apache.cxf.transport.DestinationFactory"/>
<property name="idsProperty" value="transportIds"/>
</bean>
</property>
<property name="bus" ref="cxf"/>
</bean> <bean id="org.apache.cxf.transport.ConduitInitiatorManager" class="org.apache.cxf.transport.ConduitInitiatorManagerImpl">
<property name="mapProvider">
<bean class="org.apache.cxf.configuration.spring.SpringBeanMap">
<property name="type" value="org.apache.cxf.transport.ConduitInitiator"/>
<property name="idsProperty" value="transportIds"/>
</bean>
</property>
<property name="bus" ref="cxf"/>
</bean> <bean id="org.apache.cxf.wsdl.WSDLManager" class="org.apache.cxf.wsdl11.WSDLManagerImpl">
<property name="bus" ref="cxf"/>
</bean> <bean id="org.apache.cxf.phase.PhaseManager" class="org.apache.cxf.phase.PhaseManagerImpl"> </bean> <bean id="org.apache.cxf.workqueue.WorkQueueManager" class="org.apache.cxf.workqueue.WorkQueueManagerImpl">
<property name="bus" ref="cxf"/>
</bean> <bean id="org.apache.cxf.buslifecycle.BusLifeCycleManager" class="org.apache.cxf.buslifecycle.CXFBusLifeCycleManager">
<property name="bus" ref="cxf"/>
</bean> <bean id="org.apache.cxf.endpoint.ServerRegistry" class="org.apache.cxf.endpoint.ServerRegistryImpl">
<property name="bus" ref="cxf"/>
</bean> <bean id="org.apache.cxf.endpoint.ServerLifeCycleManager" class="org.apache.cxf.endpoint.ServerLifeCycleManagerImpl"/>
<bean id="org.apache.cxf.endpoint.ClientLifeCycleManager" class="org.apache.cxf.endpoint.ClientLifeCycleManagerImpl"/> <bean id="org.apache.cxf.transports.http.QueryHandlerRegistry" class="org.apache.cxf.transport.http.QueryHandlerRegistryImpl">
<property name="bus" ref="cxf"/>
<property name="queryHandlers">
<list>
<bean class="org.apache.cxf.transport.http.WSDLQueryHandler">
<property name="bus" ref="cxf"/>
</bean>
</list>
</property>
</bean> <bean id="org.apache.cxf.endpoint.EndpointResolverRegistry" class="org.apache.cxf.endpoint.EndpointResolverRegistryImpl">
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.headers.HeaderManager" class="org.apache.cxf.headers.HeaderManagerImpl">
<property name="bus" ref="cxf"/>
</bean>
<bean id="org.apache.cxf.catalog.OASISCatalogManager" class="org.apache.cxf.catalog.OASISCatalogManager">
<property name="bus" ref="cxf"/>
</bean> <bean id="org.apache.cxf.endpoint.ServiceContractResolverRegistry" class="org.apache.cxf.endpoint.ServiceContractResolverRegistryImpl">
<property name="bus" ref="cxf"/>
</bean>
</beans>
定义了id 是 cxf 的bean ,以供其他bean 引用。
定义了其他bean
cxf-extension-soap.xml 位于cxf-rt-bindings-soap-2.1.3.jar
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
--> <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:foo="http://cxf.apache.org/configuration/foo"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="org.apache.cxf.binding.soap.SoapBindingFactory"
class="org.apache.cxf.binding.soap.SoapBindingFactory" lazy-init="true">
<property name="activationNamespaces">
<set>
<value>http://schemas.xmlsoap.org/soap/</value>
<value>http://schemas.xmlsoap.org/wsdl/soap/</value>
<value>http://schemas.xmlsoap.org/wsdl/soap12/</value>
<value>http://www.w3.org/2003/05/soap/bindings/HTTP/</value>
<value>http://schemas.xmlsoap.org/wsdl/soap/http</value>
</set>
</property>
<property name="bus" ref="cxf"/>
</bean> <bean class="org.apache.cxf.binding.soap.SoapTransportFactory"
id="org.apache.cxf.binding.soap.SoapTransportFactory"
lazy-init="true">
<property name="transportIds">
<list>
<value>http://schemas.xmlsoap.org/soap/</value>
<value>http://schemas.xmlsoap.org/wsdl/soap/</value>
<value>http://schemas.xmlsoap.org/wsdl/soap12/</value>
</list>
</property>
<property name="bus" ref="cxf"/>
</bean> <bean id="org.apache.cxf.binding.soap.customEditorConfigurer"
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="org.apache.cxf.binding.soap.SoapVersion">
<bean class="org.apache.cxf.binding.soap.SoapVersionEditor"/>
</entry>
</map>
</property>
</bean>
</beans>
cxf-servlet.xml 位于 cxf-rt-transports-http-2.1.3.jar
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:foo="http://cxf.apache.org/configuration/foo"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean class="org.apache.cxf.transport.servlet.ServletTransportFactory"
id="org.apache.cxf.transport.servlet.ServletTransportFactory">
<property name="bus" ref="cxf"/>
<property name="transportIds">
<set>
<value>http://cxf.apache.org/bindings/xformat</value>
<value>http://schemas.xmlsoap.org/soap/http</value>
<value>http://schemas.xmlsoap.org/wsdl/http/</value>
<value>http://schemas.xmlsoap.org/wsdl/soap/http</value>
<value>http://www.w3.org/2003/05/soap/bindings/HTTP/</value>
<value>http://cxf.apache.org/transports/http/configuration</value>
</set>
</property>
</bean>
</beans>
2. jaxws
http://cxf.apache.org/schemas/jaxws.xsd
这个xml语法定义中提供了三个:
- <jaxws:endpoint></jaxws:endpoint>
- <jaxws:server></jaxws:server>
- <jaxws:client></jaxws:client>
endpoint 与 server 的区别:
cxf的发布方式↓
package ws.run; import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean; import cn.zno.ws.service.CleanService;
import cn.zno.ws.serviceImpl.CleanServiceImpl; public class Run { public static void main(String[] args) {
CleanServiceImpl implementor = new CleanServiceImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setServiceClass(CleanService.class);
svrFactory.setAddress("http://localhost:9000/clean");
svrFactory.setServiceBean(implementor);
svrFactory.getInInterceptors().add(new LoggingInInterceptor());
svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
svrFactory.create();
}
}
标准的发布服务方式↓
package ws.run; import javax.xml.ws.Endpoint; import cn.zno.ws.serviceImpl.CleanServiceImpl; public class Run { public static void main(String[] args) {
Endpoint.publish("http://localhost:9000/clean", new CleanServiceImpl());
}
}
配置 cxf-ws spring bean 文件的更多相关文章
- 配置 cxf-rs spring bean 文件
http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/docs/restful-services.html 示例: <?xm ...
- Spring Bean几种注入方式——setter(常用),构造器,注入内部Bean,注入集合,接口...
依赖注入分为三种方式: 1.1构造器注入 构造器通过构造方法实现,构造方法有无参数都可以.在大部分情况下我们都是通过类的构造器来创建对象,Spring也可以采用反射机制通过构造器完成注入,这就是构造器 ...
- 【Spring】IoC容器 - Spring Bean作用域Scope(含SpringCloud中的RefreshScope )
前言 上一章学习了[依赖来源],本章主要讨论SpringBean的作用域,我们这里讨论的Bean的作用域,很大程度都是默认只讨论依赖来源为[Spring BeanDefinition]的作用域,因为在 ...
- Spring配置bean文件的底层实现方式
首先 bean文件如下: <beans> <bean id="date" class="java.util.Date"></bea ...
- Spring基础——在Spring Config 文件中配置 Bean
一.基于 XML 的 Bean 的配置——通过全类名(反射) <bean <!-- id: bean 的名称在IOC容器内必须是唯一的若没有指定,则自动的将全限定类名作为 改 bean 的 ...
- Spring bean工厂配置头文件
命名 beans.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=" ...
- CXF和spring整合遇到的问题:No bean named 'cxf' is defined
今天在做ws和spring整合的时候,很不幸的遇到了这个问题,百度了好久,竟然没人遇到这个问题,后来谷歌了一下,都是遇到这个问题的了...在看到一篇文章中提到了cxf.xml,所以我果断的打开这个配置 ...
- webservice 服务端例子+客户端例子+CXF整合spring服务端测试+生成wsdl文件 +cxf客户端代码自动生成
首先到CXF官网及spring官网下载相关jar架包,这个不多说.webservice是干嘛用的也不多说. 入门例子 模拟新增一个用户,并返回新增结果,成功还是失败. 大概的目录如上,很简单. Res ...
- [原创]java WEB学习笔记98:Spring学习---Spring Bean配置及相关细节:如何在配置bean,Spring容器(BeanFactory,ApplicationContext),如何获取bean,属性赋值(属性注入,构造器注入),配置bean细节(字面值,包含特殊字符,引用bean,null值,集合属性list map propert),util 和p 命名空间
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
随机推荐
- objective C, parse json时注意事项
例: dict为从API请求返回的json调用 NSJSONSerialization JSONObjectWithData:方法得到的NSDictionary实例. 当执行以下语句时linkStri ...
- iphone splash screen
https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articl ...
- Asp.Net Core参考资料
Every day up!!!!!! 1.Asp.Net官方文档 2.<Professional C# 6 and .NET Core 1.0> 翻译 3.ASP.NET Core中文文档 ...
- 使用robotium对android应用进行自动化测试
所需要的环境: 1.eclipse 2.android development tools(ADT) 3.software develoment kit(SDK) 4.JDK 5.robotium 1 ...
- 获得Variant类型
function GetVariantType(const v: variant): string; begin case TVarData(v).vType of varEmpty: r ...
- 面向对象三大特性一一封装(encapsulation)
为什么要封装? 我们看电视,只要按一下开关和换台就行了.有必要了解电视的内部结构吗?有必要了解显像管吗? 封装是为了隐藏对象内部的复杂性,只对外公开简单的接口.便于外界调用,从而提高系统的可扩展性,可 ...
- cookie保存用户名及密码
登陆页中,用户输入用户名密码,点击提交,后台对照mysq数据库中,看是否有对应的用户名,以及密码是否正确.如果正确 则将用户名密码分两份Cookie保存.页面跳转到登陆成功页. 用户再次访问登陆页时, ...
- How to create a Virtual Machine in SmartOS
在SmartOS中,使用vmadm创建工具创建虚拟机. 此工具需要一个JSON有效负载,并使用输入JSON中指定的属性创建“kvm”或“joyent” brand zone. 正常输出是一系列单行JS ...
- R语言做条形图时候,离散变量和连续型变量的区别
1)条形图 条形图或许是最常用图形,常用来展示分类(different categories on the x-axis)和数值(numeric values on the y-axis)之间的关系. ...
- 安装RabbitMq-----windows
在官网download我们所需要的版本,安装rabbitMq需要erlang支持 rabbitMq :http://www.rabbitmq.com/download.html erlang :ht ...