CXF WebService整合Spring
2013-05-28 23:50
429 查看
首先,CXF和spring整合需要准备如下jar包文件:
这边我是用Spring的jar包是Spring官方提供的,并没有使用CXF中的Spring的jar文件。
添加这么多文件后,首先在web.xml中添加如下配置:
然后在src目录中,新建一个applicationContext-server.xml文件,文件内容如下:
注意上面的带下划线加粗部分,这个很重要的哦!不能写错或是遗漏了。
下面开始写服务器端代码,首先定制服务器端的接口,代码如下:
注意的是和Spring集成,这里一定要完成接口实现,如果没有接口的话会有错误的。
在服务器启动前加入log4j的配置:
下面启动tomcat服务器后,在WebBrowser中请求:
http://127.0.0.1:8080/cxf_spring/Users?wsdl
如果你能看到wsdl的xml文件的内容,就说明你成功了,注意的是上面地址的Users就是上面xml配置中的address的名称,是一一对应的。
下面编写客户端请求的代码,代码如下:
运行后结果如下:
2013-5-28 23:50:14 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: F:\Program Files\Genuitec\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\bin;F:\Tomcat 6.0\bin
2013-5-28 23:50:15 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2013-5-28 23:50:15 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 647 ms
2013-5-28 23:50:15 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2013-5-28 23:50:15 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.32
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory cxf_spring
2013-5-28 23:50:16 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2013-05-28 23:50:16,468 INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
2013-05-28 23:50:16,781 INFO org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue May 28 23:50:16 CST 2013]; root of context hierarchy
2013-05-28 23:50:16,937 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [file:/F:/Tomcat%206.0/webapps/cxf_spring/WEB-INF/classes/applicationContext-server.xml]
2013-05-28 23:50:17,062 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
2013-05-28 23:50:17,125 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml]
2013-05-28 23:50:17,140 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
2013-05-28 23:50:17,156 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-http.xml]
2013-05-28 23:50:17,734 INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6de609: defining beans [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.service.factory.FactoryBeanListenerManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.cxf.transport.servlet.ServletTransportFactory,userServiceBean,inMessageInterceptor,outLoggingInterceptor,userService];
root of factory hierarchy
2013-5-28 23:50:18 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://service.hoo.com/}IComplexUserServiceService from class com.hoo.service.IComplexUserService
2013-5-28 23:50:19 org.apache.cxf.endpoint.ServerImpl initDestination
信息: Setting the server's publish address to be /Users
2013-05-28 23:50:19,218 INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 2750 ms
2013-5-28 23:50:19 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2013-5-28 23:50:19 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2013-5-28 23:50:19 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/47 config=null
2013-5-28 23:50:19 org.apache.catalina.startup.Catalina start
信息: Server startup in 4383 ms
2013-5-28 23:51:09 org.apache.cxf.transport.servlet.CXFServlet updateContext
信息: Load the bus with application context
2013-05-28 23:51:09,937 INFO org.apache.cxf.bus.spring.BusApplicationContext - Refreshing org.apache.cxf.bus.spring.BusApplicationContext@4d2b11: startup date [Tue May 28 23:51:09 CST 2013]; parent: Root WebApplicationContext
2013-05-28 23:51:09,937 INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@13a95af: defining beans []; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@6de609
2013-5-28 23:51:09 org.apache.cxf.transport.servlet.AbstractCXFServlet replaceDestinationFactory
信息: Servlet transport factory already registered
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1eeba19, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1eeba19, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
2013-5-28 23:51:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 1
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:getUserByNameResponse xmlns:ns1="http://service.hoo.com/"><return><address>china</address><email>e421083458@163.com</email><id>10</id><name>e421083458</name></return></ns1:getUserByNameResponse></soap:Body></soap:Envelope>
--------------------------------------
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[276], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@b27c38, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[276], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@b27c38, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
##########Server setUser############
setUser:com.hoo.entity.User@14653a3
2013-5-28 23:51:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 2
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:setUserResponse xmlns:ns1="http://service.hoo.com/"></ns1:setUserResponse></soap:Body></soap:Envelope>
--------------------------------------
这个server端是通过Spring整合配置的,下面我们将Client端也通过Spring配置完成整合。
首先增加applicationContext-client.xml配置文件,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<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:client id="userWsClient" serviceClass="com.hoo.service.IComplexUserService"
address="http://127.0.0.1:8080/cxf_spring/Users"/>
</beans>
客户端请求代码如下:
package com.hoo.client;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.hoo.entity.User;
import com.hoo.service.IComplexUserService;
public class SpringUsersWsClient {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext-client.xml");
IComplexUserService service = ctx.getBean("userWsClient", IComplexUserService.class);
System.out.println("#############Client getUserByName##############");
User user = service.getUserByName("e421083458");
System.out.println(user);
user.setAddress("China-Guangzhou");
service.setUser(user);
}
}
运行后结果如下:
2013-5-28 23:50:14 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: F:\Program Files\Genuitec\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\bin;F:\Tomcat 6.0\bin
2013-5-28 23:50:15 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2013-5-28 23:50:15 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 647 ms
2013-5-28 23:50:15 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2013-5-28 23:50:15 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.32
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory cxf_spring
2013-5-28 23:50:16 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2013-05-28 23:50:16,468 INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
2013-05-28 23:50:16,781 INFO org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue May 28 23:50:16 CST 2013]; root of context hierarchy
2013-05-28 23:50:16,937 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [file:/F:/Tomcat%206.0/webapps/cxf_spring/WEB-INF/classes/applicationContext-server.xml]
2013-05-28 23:50:17,062 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
2013-05-28 23:50:17,125 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml]
2013-05-28 23:50:17,140 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
2013-05-28 23:50:17,156 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-http.xml]
2013-05-28 23:50:17,734 INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6de609: defining beans [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.service.factory.FactoryBeanListenerManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.cxf.transport.servlet.ServletTransportFactory,userServiceBean,inMessageInterceptor,outLoggingInterceptor,userService];
root of factory hierarchy
2013-5-28 23:50:18 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://service.hoo.com/}IComplexUserServiceService from class com.hoo.service.IComplexUserService
2013-5-28 23:50:19 org.apache.cxf.endpoint.ServerImpl initDestination
信息: Setting the server's publish address to be /Users
2013-05-28 23:50:19,218 INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 2750 ms
2013-5-28 23:50:19 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2013-5-28 23:50:19 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2013-5-28 23:50:19 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/47 config=null
2013-5-28 23:50:19 org.apache.catalina.startup.Catalina start
信息: Server startup in 4383 ms
2013-5-28 23:51:09 org.apache.cxf.transport.servlet.CXFServlet updateContext
信息: Load the bus with application context
2013-05-28 23:51:09,937 INFO org.apache.cxf.bus.spring.BusApplicationContext - Refreshing org.apache.cxf.bus.spring.BusApplicationContext@4d2b11: startup date [Tue May 28 23:51:09 CST 2013]; parent: Root WebApplicationContext
2013-05-28 23:51:09,937 INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@13a95af: defining beans []; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@6de609
2013-5-28 23:51:09 org.apache.cxf.transport.servlet.AbstractCXFServlet replaceDestinationFactory
信息: Servlet transport factory already registered
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1eeba19, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1eeba19, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
2013-5-28 23:51:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 1
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:getUserByNameResponse xmlns:ns1="http://service.hoo.com/"><return><address>china</address><email>e421083458@163.com</email><id>10</id><name>e421083458</name></return></ns1:getUserByNameResponse></soap:Body></soap:Envelope>
--------------------------------------
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[276], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@b27c38, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[276], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@b27c38, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
##########Server setUser############
setUser:com.hoo.entity.User@14653a3
2013-5-28 23:51:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 2
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:setUserResponse xmlns:ns1="http://service.hoo.com/"></ns1:setUserResponse></soap:Body></soap:Envelope>
--------------------------------------
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1ed00d1, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1ed00d1, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
2013-5-28 23:53:20 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 3
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:getUserByNameResponse xmlns:ns1="http://service.hoo.com/"><return><address>china</address><email>e421083458@163.com</email><id>20</id><name>e421083458</name></return></ns1:getUserByNameResponse></soap:Body></soap:Envelope>
--------------------------------------
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[286], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@170119f, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[286], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@170119f, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
##########Server setUser############
setUser:com.hoo.entity.User@94fe42
2013-5-28 23:53:20 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 4
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:setUserResponse xmlns:ns1="http://service.hoo.com/"></ns1:setUserResponse></soap:Body></soap:Envelope>
--------------------------------------
这边我是用Spring的jar包是Spring官方提供的,并没有使用CXF中的Spring的jar文件。
添加这么多文件后,首先在web.xml中添加如下配置:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <display-name></display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- 加载Spring容器配置 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 设置Spring容器加载配置文件路径 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext-server.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <servlet> <servlet-name>CXFService</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>CXFService</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app>
然后在src目录中,新建一个applicationContext-server.xml文件,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <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"/> <bean id="userServiceBean" class="com.hoo.service.ComplexUserService"/> <bean id="inMessageInterceptor" class="com.hoo.interceptor.MessageInterceptor"> <constructor-arg value="receive"/> </bean> <bean id="outLoggingInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/> <!-- 注意下面的address,这里的address的名称就是访问的WebService的name --> <jaxws:server id="userService" serviceClass="com.hoo.service.IComplexUserService" address="/Users"> <jaxws:serviceBean> <!-- 要暴露的 bean 的引用 --> <ref bean="userServiceBean"/> </jaxws:serviceBean> <jaxws:inInterceptors> <ref bean="inMessageInterceptor"/> </jaxws:inInterceptors> <jaxws:outInterceptors> <ref bean="outLoggingInterceptor"/> </jaxws:outInterceptors> </jaxws:server> </beans>
注意上面的带下划线加粗部分,这个很重要的哦!不能写错或是遗漏了。
下面开始写服务器端代码,首先定制服务器端的接口,代码如下:
package com.hoo.service; import javax.jws.WebParam; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.soap.SOAPBinding.Style; import com.hoo.entity.User; @WebService @SOAPBinding(style = Style.RPC) public interface IComplexUserService { public User getUserByName(@WebParam(name = "name") String name); public void setUser(User user); } 下面编写WebService的实现类,服务器端实现代码如下: package com.hoo.service; import java.util.Date; import javax.jws.WebParam; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.soap.SOAPBinding.Style; import com.hoo.entity.User; @WebService @SOAPBinding(style = Style.RPC) @SuppressWarnings("deprecation") public class ComplexUserService implements IComplexUserService { @Override public User getUserByName(@WebParam(name = "name") String name) { User user = new User(); user.setId(new Date().getSeconds()); user.setName(name); user.setAddress("china"); user.setEmail(name + "@163.com"); return user; } @Override public void setUser(User user) { System.out.println("##########Server setUser############"); System.out.println("setUser:" + user); } }
注意的是和Spring集成,这里一定要完成接口实现,如果没有接口的话会有错误的。
在服务器启动前加入log4j的配置:
# This is the configuring for logging displayed in the Application Server log4j.rootCategory=INFO, stdout,common-default,common-warn,common-error ################################ # common appenders ################################ #stdout configure log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.conversionPattern= %d %-5p %c - %m%n #common-default file appender log4j.appender.common-default=org.apache.log4j.DailyRollingFileAppender log4j.appender.common-default.file=../logs/common-default.log log4j.appender.common-default.layout=org.apache.log4j.PatternLayout log4j.appender.common-default.layout.conversionPattern= %d %-5p %c - %m%n #common-warn file appender log4j.appender.common-warn=org.apache.log4j.DailyRollingFileAppender log4j.appender.common-warn.file=../logs/common-warn.log log4j.appender.common-warn.layout=org.apache.log4j.PatternLayout log4j.appender.common-warn.filter.ID=org.apache.log4j.varia.LevelRangeFilter log4j.appender.common-warn.filter.ID.levelMin=WARN log4j.appender.common-warn.filter.ID.levelMax=WARN log4j.appender.common-warn.layout.conversionPattern= %d %-5p %c - %m%n #common-error file appender log4j.appender.common-error=org.apache.log4j.DailyRollingFileAppender log4j.appender.common-error.file=../logs/common-error.log log4j.appender.common-error.layout=org.apache.log4j.PatternLayout log4j.appender.common-error.threshold=ERROR log4j.appender.common-error.layout.conversionPattern= %d %-5p %c - %m%n #common-dao file appender log4j.appender.common-dao=org.apache.log4j.DailyRollingFileAppender log4j.appender.common-dao.file=../logs/common-dao.log log4j.appender.common-dao.layout=org.apache.log4j.PatternLayout log4j.appender.common-dao.layout.conversionPattern= %d %-5p %c - %m%n #common-web file appender log4j.appender.common-web=org.apache.log4j.DailyRollingFileAppender log4j.appender.common-web.file=../logs/common-web.log log4j.appender.common-web.layout=org.apache.log4j.PatternLayout log4j.appender.common-web.layout.conversionPattern= %d %-5p %c - %m%n #common-pageNotFound file appender log4j.appender.common-pageNotFound=org.apache.log4j.DailyRollingFileAppender log4j.appender.common-pageNotFound.file=../logs/common-pageNotFound.log log4j.appender.common-pageNotFound.layout=org.apache.log4j.PatternLayout log4j.appender.common-pageNotFound.layout.conversionPattern= %d %-5p %c - %m%n ################################ # project appenders ################################ #project-dao file appender log4j.appender.project-dao=org.apache.log4j.DailyRollingFileAppender log4j.appender.project-dao.file=../logs/project-dao.log log4j.appender.project-dao.layout=org.apache.log4j.PatternLayout log4j.appender.project-dao.threshold=INFO log4j.appender.project-dao.layout.conversionPattern= %d %-5p %c - %m%n #project-web file appender log4j.appender.project-web=org.apache.log4j.DailyRollingFileAppender log4j.appender.project-web.file=../logs/project-web.log log4j.appender.project-web.layout=org.apache.log4j.PatternLayout log4j.appender.project-web.threshold=INFO log4j.appender.project-web.layout.conversionPattern= %d %-5p %c - %m%n #project-service file appender log4j.appender.project-service=org.apache.log4j.DailyRollingFileAppender log4j.appender.project-service.file=../logs/project-service.log log4j.appender.project-service.layout=org.apache.log4j.PatternLayout log4j.appender.project-service.threshold=INFO log4j.appender.project-service.layout.conversionPattern= %d %-5p %c - %m%n ################################ # open source framework loggers ################################ #spring log4j.logger.org.springframework=INFO log4j.logger.org.springframework.jdbc.core.JdbcTemplate=DEBUG,common-dao # debug log for ibatis2.3 #log4j.logger.java.sql.Connection=DEBUG,common-dao #log4j.logger.java.sql.Statement=INFO,common-dao #log4j.logger.java.sql.PreparedStatement=INFO,common-dao #log4j.logger.java.sql.ResultSet=INFO,common-dao # debug log for ibatis3 log4j.logger.java.sql.Connection=DEBUG,common-dao log4j.logger.java.sql.Statement=DEBUG,common-dao log4j.logger.java.sql.PreparedStatement=DEBUG,common-dao log4j.logger.java.sql.ResultSet=INFO,common-dao # hibernate: Changing the log level to DEBUG will display SQL Hibernate generated log4j.logger.org.hibernate=INFO,common-dao log4j.logger.org.hibernate.SQL=ERROR log4j.logger.org.hibernate.cache=ERROR log4j.logger.net.sf.ehcache=ERROR #springmvc pageNotFound log4j.logger.org.springframework.web.servlet.PageNotFound=INFO,common-pageNotFound #HibernateValidator log4j.logger.org.apache.commons.validator.ValidatorResources=INFO #log4jdbc, see: http://code.google.com/p/rapid-framework/wiki/log4jdbc for details log4j.logger.jdbc.sqlonly=OFF log4j.logger.jdbc.sqltiming=INFO,common-dao log4j.logger.jdbc.audit=OFF log4j.logger.jdbc.resultset=OFF log4j.logger.jdbc.connection=OFF ################################ # project loggers ################################ log4j.logger.com.bjsxt.registration.dao=INFO,project-dao log4j.logger.com.bjsxt.registration.service=INFO,project-service log4j.logger.com.bjsxt.registration.action=INFO,project-web
下面启动tomcat服务器后,在WebBrowser中请求:
http://127.0.0.1:8080/cxf_spring/Users?wsdl
如果你能看到wsdl的xml文件的内容,就说明你成功了,注意的是上面地址的Users就是上面xml配置中的address的名称,是一一对应的。
下面编写客户端请求的代码,代码如下:
package com.hoo.client; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.hoo.entity.User; import com.hoo.service.IComplexUserService; public class SpringUsersWsClient { public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext-client.xml"); IComplexUserService service = ctx.getBean("userWsClient", IComplexUserService.class); System.out.println("#############Client getUserByName##############"); User user = service.getUserByName("e421083458"); System.out.println(user); user.setAddress("China-Guangzhou"); service.setUser(user); } }
运行后结果如下:
2013-5-28 23:50:14 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: F:\Program Files\Genuitec\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\bin;F:\Tomcat 6.0\bin
2013-5-28 23:50:15 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2013-5-28 23:50:15 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 647 ms
2013-5-28 23:50:15 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2013-5-28 23:50:15 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.32
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory cxf_spring
2013-5-28 23:50:16 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2013-05-28 23:50:16,468 INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
2013-05-28 23:50:16,781 INFO org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue May 28 23:50:16 CST 2013]; root of context hierarchy
2013-05-28 23:50:16,937 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [file:/F:/Tomcat%206.0/webapps/cxf_spring/WEB-INF/classes/applicationContext-server.xml]
2013-05-28 23:50:17,062 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
2013-05-28 23:50:17,125 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml]
2013-05-28 23:50:17,140 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
2013-05-28 23:50:17,156 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-http.xml]
2013-05-28 23:50:17,734 INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6de609: defining beans [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.service.factory.FactoryBeanListenerManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.cxf.transport.servlet.ServletTransportFactory,userServiceBean,inMessageInterceptor,outLoggingInterceptor,userService];
root of factory hierarchy
2013-5-28 23:50:18 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://service.hoo.com/}IComplexUserServiceService from class com.hoo.service.IComplexUserService
2013-5-28 23:50:19 org.apache.cxf.endpoint.ServerImpl initDestination
信息: Setting the server's publish address to be /Users
2013-05-28 23:50:19,218 INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 2750 ms
2013-5-28 23:50:19 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2013-5-28 23:50:19 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2013-5-28 23:50:19 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/47 config=null
2013-5-28 23:50:19 org.apache.catalina.startup.Catalina start
信息: Server startup in 4383 ms
2013-5-28 23:51:09 org.apache.cxf.transport.servlet.CXFServlet updateContext
信息: Load the bus with application context
2013-05-28 23:51:09,937 INFO org.apache.cxf.bus.spring.BusApplicationContext - Refreshing org.apache.cxf.bus.spring.BusApplicationContext@4d2b11: startup date [Tue May 28 23:51:09 CST 2013]; parent: Root WebApplicationContext
2013-05-28 23:51:09,937 INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@13a95af: defining beans []; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@6de609
2013-5-28 23:51:09 org.apache.cxf.transport.servlet.AbstractCXFServlet replaceDestinationFactory
信息: Servlet transport factory already registered
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1eeba19, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1eeba19, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
2013-5-28 23:51:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 1
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:getUserByNameResponse xmlns:ns1="http://service.hoo.com/"><return><address>china</address><email>e421083458@163.com</email><id>10</id><name>e421083458</name></return></ns1:getUserByNameResponse></soap:Body></soap:Envelope>
--------------------------------------
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[276], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@b27c38, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[276], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@b27c38, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
##########Server setUser############
setUser:com.hoo.entity.User@14653a3
2013-5-28 23:51:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 2
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:setUserResponse xmlns:ns1="http://service.hoo.com/"></ns1:setUserResponse></soap:Body></soap:Envelope>
--------------------------------------
这个server端是通过Spring整合配置的,下面我们将Client端也通过Spring配置完成整合。
首先增加applicationContext-client.xml配置文件,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<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:client id="userWsClient" serviceClass="com.hoo.service.IComplexUserService"
address="http://127.0.0.1:8080/cxf_spring/Users"/>
</beans>
客户端请求代码如下:
package com.hoo.client;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.hoo.entity.User;
import com.hoo.service.IComplexUserService;
public class SpringUsersWsClient {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext-client.xml");
IComplexUserService service = ctx.getBean("userWsClient", IComplexUserService.class);
System.out.println("#############Client getUserByName##############");
User user = service.getUserByName("e421083458");
System.out.println(user);
user.setAddress("China-Guangzhou");
service.setUser(user);
}
}
运行后结果如下:
2013-5-28 23:50:14 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: F:\Program Files\Genuitec\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\bin;F:\Tomcat 6.0\bin
2013-5-28 23:50:15 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2013-5-28 23:50:15 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 647 ms
2013-5-28 23:50:15 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2013-5-28 23:50:15 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.32
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2013-5-28 23:50:15 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory cxf_spring
2013-5-28 23:50:16 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2013-05-28 23:50:16,468 INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
2013-05-28 23:50:16,781 INFO org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue May 28 23:50:16 CST 2013]; root of context hierarchy
2013-05-28 23:50:16,937 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [file:/F:/Tomcat%206.0/webapps/cxf_spring/WEB-INF/classes/applicationContext-server.xml]
2013-05-28 23:50:17,062 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
2013-05-28 23:50:17,125 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml]
2013-05-28 23:50:17,140 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
2013-05-28 23:50:17,156 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-http.xml]
2013-05-28 23:50:17,734 INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6de609: defining beans [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.service.factory.FactoryBeanListenerManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.cxf.transport.servlet.ServletTransportFactory,userServiceBean,inMessageInterceptor,outLoggingInterceptor,userService];
root of factory hierarchy
2013-5-28 23:50:18 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://service.hoo.com/}IComplexUserServiceService from class com.hoo.service.IComplexUserService
2013-5-28 23:50:19 org.apache.cxf.endpoint.ServerImpl initDestination
信息: Setting the server's publish address to be /Users
2013-05-28 23:50:19,218 INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 2750 ms
2013-5-28 23:50:19 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2013-5-28 23:50:19 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2013-5-28 23:50:19 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/47 config=null
2013-5-28 23:50:19 org.apache.catalina.startup.Catalina start
信息: Server startup in 4383 ms
2013-5-28 23:51:09 org.apache.cxf.transport.servlet.CXFServlet updateContext
信息: Load the bus with application context
2013-05-28 23:51:09,937 INFO org.apache.cxf.bus.spring.BusApplicationContext - Refreshing org.apache.cxf.bus.spring.BusApplicationContext@4d2b11: startup date [Tue May 28 23:51:09 CST 2013]; parent: Root WebApplicationContext
2013-05-28 23:51:09,937 INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@13a95af: defining beans []; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@6de609
2013-5-28 23:51:09 org.apache.cxf.transport.servlet.AbstractCXFServlet replaceDestinationFactory
信息: Servlet transport factory already registered
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1eeba19, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1eeba19, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
2013-5-28 23:51:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 1
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:getUserByNameResponse xmlns:ns1="http://service.hoo.com/"><return><address>china</address><email>e421083458@163.com</email><id>10</id><name>e421083458</name></return></ns1:getUserByNameResponse></soap:Body></soap:Envelope>
--------------------------------------
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[276], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@b27c38, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[276], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@b27c38, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
##########Server setUser############
setUser:com.hoo.entity.User@14653a3
2013-5-28 23:51:10 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 2
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:setUserResponse xmlns:ns1="http://service.hoo.com/"></ns1:setUserResponse></soap:Body></soap:Envelope>
--------------------------------------
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1ed00d1, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[207], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1ed00d1, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
2013-5-28 23:53:20 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 3
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:getUserByNameResponse xmlns:ns1="http://service.hoo.com/"><return><address>china</address><email>e421083458@163.com</email><id>20</id><name>e421083458</name></return></ns1:getUserByNameResponse></soap:Body></soap:Envelope>
--------------------------------------
############handleMessage##########
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[286], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@170119f, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}
null#org.apache.cxf.transport.ChainInitiationObserver@47098a
{org.apache.cxf.message.Message.PROTOCOL_HEADERS={cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[127.0.0.1:8080], Content-Length=[286], SOAPAction=[""], user-agent=[Apache CXF 2.3.3], Content-Type=[text/xml;
charset=UTF-8], Accept=[*/*], pragma=[no-cache]}, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@196eed5], org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null,
HTTP.RESPONSE=org.apache.catalina.connector.ResponseFacade@1a1b2f, org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@170119f, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true,
org.apache.cxf.request.uri=/cxf_spring/Users, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.servlet.ServletDestination@1bc6533, HTTP.REQUEST=org.apache.catalina.connector.RequestFacade@19811ce,
HTTP.CONFIG=org.apache.catalina.core.StandardWrapperFacade@b8f675, org.apache.cxf.transport.https.CertConstraints=null, Accept=*/*, Content-Type=text/xml; charset=UTF-8, HTTP.CONTEXT=org.apache.catalina.core.ApplicationContextFacade@13c9557, org.apache.cxf.message.Message.BASE_PATH=/cxf_spring/Users,
org.apache.cxf.message.Message.PATH_INFO=/cxf_spring/Users}#null
null#null
##########Server setUser############
setUser:com.hoo.entity.User@94fe42
2013-5-28 23:53:20 org.apache.cxf.interceptor.AbstractLoggingInterceptor log
信息: Outbound Message
---------------------------
ID: 4
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:setUserResponse xmlns:ns1="http://service.hoo.com/"></ns1:setUserResponse></soap:Body></soap:Envelope>
--------------------------------------
相关文章推荐
- WebService系列博客{十一}[CXF整合spring实际案例]
- CXF整合Spring开发WebService
- Web Service学习-CXF与Spring整合为JavaEE应用发布WebService(三)
- 【WebService】——CXF整合Spring
- webservice快速入门-使用spring整合apache-cxf(五)
- CXF WebService 7 - Spring整合CXF,发布RSETful 风格WebService
- webservice--CXF+Spring整合发布REST的服务
- 五、CXF WebService整合Spring
- spring 与 CXF 整合 webservice 出现error “Unable to locate Spring NamespaceHandler for XML schema namespace” 总结
- webService之(五)Spring与CXF整合
- WebService学习笔记(六)Spring与CXF整合服务端
- webservice快速入门-使用spring整合apache-cxf(五)
- Maven+SpringMVC+CXF整合实现webservice服务的发布与调用
- WebService-CXF和spring整合实现webservice案例(Spring配置注解环境)
- Spring整合CXF,发布RSETful 风格WebService
- CXF webservice整合spring 小例子
- Spring整合CXF,发布RSETful 风格WebService
- WebService --- Spring整合CXF --- WS
- Spring整合CXF,发布RSETful 风格WebService-准备工作
- CXF与Spring整合开发WebService服务