<?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 文件的更多相关文章

  1. 配置 cxf-rs spring bean 文件

    http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/docs/restful-services.html 示例: <?xm ...

  2. Spring Bean几种注入方式——setter(常用),构造器,注入内部Bean,注入集合,接口...

    依赖注入分为三种方式: 1.1构造器注入 构造器通过构造方法实现,构造方法有无参数都可以.在大部分情况下我们都是通过类的构造器来创建对象,Spring也可以采用反射机制通过构造器完成注入,这就是构造器 ...

  3. 【Spring】IoC容器 - Spring Bean作用域Scope(含SpringCloud中的RefreshScope )

    前言 上一章学习了[依赖来源],本章主要讨论SpringBean的作用域,我们这里讨论的Bean的作用域,很大程度都是默认只讨论依赖来源为[Spring BeanDefinition]的作用域,因为在 ...

  4. Spring配置bean文件的底层实现方式

    首先 bean文件如下: <beans> <bean id="date" class="java.util.Date"></bea ...

  5. Spring基础——在Spring Config 文件中配置 Bean

    一.基于 XML 的 Bean 的配置——通过全类名(反射) <bean <!-- id: bean 的名称在IOC容器内必须是唯一的若没有指定,则自动的将全限定类名作为 改 bean 的 ...

  6. Spring bean工厂配置头文件

    命名 beans.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=" ...

  7. CXF和spring整合遇到的问题:No bean named 'cxf' is defined

    今天在做ws和spring整合的时候,很不幸的遇到了这个问题,百度了好久,竟然没人遇到这个问题,后来谷歌了一下,都是遇到这个问题的了...在看到一篇文章中提到了cxf.xml,所以我果断的打开这个配置 ...

  8. webservice 服务端例子+客户端例子+CXF整合spring服务端测试+生成wsdl文件 +cxf客户端代码自动生成

    首先到CXF官网及spring官网下载相关jar架包,这个不多说.webservice是干嘛用的也不多说. 入门例子 模拟新增一个用户,并返回新增结果,成功还是失败. 大概的目录如上,很简单. Res ...

  9. [原创]java WEB学习笔记98:Spring学习---Spring Bean配置及相关细节:如何在配置bean,Spring容器(BeanFactory,ApplicationContext),如何获取bean,属性赋值(属性注入,构造器注入),配置bean细节(字面值,包含特殊字符,引用bean,null值,集合属性list map propert),util 和p 命名空间

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

随机推荐

  1. 解决Linux命令行为什么变成-bash-3.2$

    在Linux服务器上创建了一个新用户probe,是这样创建的: [root@localhost home]# groupadd -g 501 probe [root@localhost home]# ...

  2. centos7部署cacti

    一.centos部署cacti 1. 关闭selinux. 2.fabric一键部署lamp 3. 设置mysql密码123456 1 mysql_secure_installation 4. 安装s ...

  3. Python 列表表达式 ,迭代器(1)

    python 环境 3.5 1.列表: s = []; for i in s: i = handleFunction(i); s.append(i) .列表 s=[handleFunction(i) ...

  4. C++ define与const

    C++中不但可以用define定义常量还可以用const定义常量,它们的区别如下: 用#define MAX 255定义的常量是没有类型的,所给出的是一个立即数,编译器只是把所定义的常量值与所定义的常 ...

  5. 43-python-自己的词典

    可以用python实现一个自己的词典, 就是在网上下一个英汉词典,作为自己的词库,然后整理出一个json文件,存起来,查词时,直接读取查询: 处理时可以用正则表达式处理: https://www.cn ...

  6. 绑定服务-----------binderService TimerTask的使用

    绑定服务 服务中通过定义Binder对象的子类让这个子类成为桥梁   在onBind()中返回子类对象 这样就可以在activity中调用这个子类的方法 在Activity中通过ServiceConn ...

  7. php下ajax的文件切割上传

    html5中的File对象继承Blob二进制对象,Blob提供了一个slice函数,可以用来切割文件数据. <!DOCTYPE HTML> <html lang="zh-C ...

  8. nginx中图片无法显示

    如果没有配置虚拟主机,则修改nginx.conf. 如果已创建单独虚拟主机,则在vhost下找到指定的主机配置文件, 如:www.xxx.com.conf location ~ .*\.(gif|jp ...

  9. [python] can not find app ,module

    can not find module 1 startapp appname 而不是 startproject 2 不要自己创建项目根目录,要用mamage.py生成 can not find app ...

  10. 电商类Web原型制作分享——聚美优品

    这是一家化妆品限时特卖商城.作为美妆电商类网站的佼佼者,网站以用户体验为核心,画面主色调符合女性消费者审美.排版整齐,布局合理.网站用弹出面板实现点击弹出内容,鼠标悬停文字按钮颜色改变等交互效果. 本 ...