<?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. cobbler配置解析

    1.Cobbler命令说明: 命令名称 命令用途 cobbler check 检查cobbler配置 cobbler list 列出所有的cobbler元素 cobbler report 列出元素的详 ...

  2. tbytes 转 十六进制 string

    function Bytes2HexStr(buf: TBytes; len: Integer): AnsiString; begin SetLength(Result, len*2);   BinT ...

  3. cmd 获取 拖拽文件名

    1. @echo off & setlocal enableDelayedExpansion set a= set /p a=Please drag your txt file for spl ...

  4. 关于时间查询的sql语句

    今天 select * from 表名 where to_days(时间字段名) = to_days(now()); 昨天 SELECT * FROM 表名 WHERE TO_DAYS( NOW( ) ...

  5. org.apache.cxf.interceptor.Fault: Unmarshalling Error: 意外的元素 (uri:"", local:"mixornot")。

    三月 09, 2018 3:09:14 下午 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging警告: Interceptor fo ...

  6. go,函数作为参数类型

    package main import "fmt" type testInt func(int) bool // 声明了一个函数类型 func isOdd(integer int) ...

  7. Spring框架整合Struts2框架的传统方法

    1. 导入CRM项目的UI页面,找到添加客户的页面,修改form表单,访问Action * 将menu.jsp中133行的新增客户的跳转地址改为:href="${pageContext.re ...

  8. Visual Studio宏

    MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)MS ...

  9. Python高级用法篇——笔记

    1.Python3字典中items()和python2.x中iteritems()的区别 在Python2.x中,items( )用于 返回一个字典的拷贝列表[Returns a copy of th ...

  10. Oracle登录命令

    1.运行SQLPLUS工具 C:\Users\wd-pc>sqlplus 2.直接进入SQLPLUS命令提示符 C:\Users\wd-pc>sqlplus /nolog 3.以OS身份连 ...